Skip to content

Commit

Permalink
feat: add support for directly attached and effective tags (#589)
Browse files Browse the repository at this point in the history
* feat: add support for directly attached and effective tags
docs: clarify comments for tags and effective tags

Clients can search resources filtered by effective tags and start to use the new `tags` field instead of old `tag_key`, `tag_value`, `tag_value_id` fields to access directly attached tags.

PiperOrigin-RevId: 567554529

Source-Link: googleapis/googleapis@1a3ea87

Source-Link: googleapis/googleapis-gen@df4f7ba
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGY0ZjdiYTQxYTgwN2ExOTNiNDhhZmRiYThkNGFlZjM1NjM2ODc1YSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Sep 29, 2023
1 parent a562a99 commit b947b2c
Show file tree
Hide file tree
Showing 9 changed files with 424 additions and 165 deletions.
4 changes: 4 additions & 0 deletions packages/google-cloud-asset/google/cloud/asset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
from google.cloud.asset_v1.types.assets import Asset
from google.cloud.asset_v1.types.assets import AttachedResource
from google.cloud.asset_v1.types.assets import ConditionEvaluation
from google.cloud.asset_v1.types.assets import EffectiveTagDetails
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisResult
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisState
from google.cloud.asset_v1.types.assets import IamPolicySearchResult
Expand All @@ -113,6 +114,7 @@
from google.cloud.asset_v1.types.assets import RelationshipAttributes
from google.cloud.asset_v1.types.assets import Resource
from google.cloud.asset_v1.types.assets import ResourceSearchResult
from google.cloud.asset_v1.types.assets import Tag
from google.cloud.asset_v1.types.assets import TemporalAsset
from google.cloud.asset_v1.types.assets import TimeWindow
from google.cloud.asset_v1.types.assets import VersionedResource
Expand Down Expand Up @@ -184,6 +186,7 @@
"Asset",
"AttachedResource",
"ConditionEvaluation",
"EffectiveTagDetails",
"IamPolicyAnalysisResult",
"IamPolicyAnalysisState",
"IamPolicySearchResult",
Expand All @@ -194,6 +197,7 @@
"RelationshipAttributes",
"Resource",
"ResourceSearchResult",
"Tag",
"TemporalAsset",
"TimeWindow",
"VersionedResource",
Expand Down
4 changes: 4 additions & 0 deletions packages/google-cloud-asset/google/cloud/asset_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
from .types.assets import Asset
from .types.assets import AttachedResource
from .types.assets import ConditionEvaluation
from .types.assets import EffectiveTagDetails
from .types.assets import IamPolicyAnalysisResult
from .types.assets import IamPolicyAnalysisState
from .types.assets import IamPolicySearchResult
Expand All @@ -95,6 +96,7 @@
from .types.assets import RelationshipAttributes
from .types.assets import Resource
from .types.assets import ResourceSearchResult
from .types.assets import Tag
from .types.assets import TemporalAsset
from .types.assets import TimeWindow
from .types.assets import VersionedResource
Expand Down Expand Up @@ -130,6 +132,7 @@
"CreateSavedQueryRequest",
"DeleteFeedRequest",
"DeleteSavedQueryRequest",
"EffectiveTagDetails",
"ExportAssetsRequest",
"ExportAssetsResponse",
"Feed",
Expand Down Expand Up @@ -174,6 +177,7 @@
"SearchAllResourcesResponse",
"TableFieldSchema",
"TableSchema",
"Tag",
"TemporalAsset",
"TimeWindow",
"UpdateFeedRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1211,62 +1211,93 @@ async def sample_search_all_resources():
Examples:
- ``name:Important`` to find Google Cloud resources
whose name contains "Important" as a word.
whose name contains ``Important`` as a word.
- ``name=Important`` to find the Google Cloud resource
whose name is exactly "Important".
whose name is exactly ``Important``.
- ``displayName:Impor*`` to find Google Cloud resources
whose display name contains "Impor" as a prefix of
whose display name contains ``Impor`` as a prefix of
any word in the field.
- ``location:us-west*`` to find Google Cloud resources
whose location contains both "us" and "west" as
whose location contains both ``us`` and ``west`` as
prefixes.
- ``labels:prod`` to find Google Cloud resources whose
labels contain "prod" as a key or value.
labels contain ``prod`` as a key or value.
- ``labels.env:prod`` to find Google Cloud resources
that have a label "env" and its value is "prod".
that have a label ``env`` and its value is ``prod``.
- ``labels.env:*`` to find Google Cloud resources that
have a label "env".
have a label ``env``.
- ``tagKeys:env`` to find Google Cloud resources that
have directly attached tags where the
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
.\ ``namespacedName`` contains ``env``.
- ``tagValues:prod*`` to find Google Cloud resources
that have directly attached tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``namespacedName`` contains a word prefixed by
``prod``.
- ``tagValueIds=tagValues/123`` to find Google Cloud
resources that have directly attached tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``name`` is exactly ``tagValues/123``.
- ``effectiveTagKeys:env`` to find Google Cloud
resources that have directly attached or inherited
tags where the
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
.\ ``namespacedName`` contains ``env``.
- ``effectiveTagValues:prod*`` to find Google Cloud
resources that have directly attached or inherited
tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``namespacedName`` contains a word prefixed by
``prod``.
- ``effectiveTagValueIds=tagValues/123`` to find Google
Cloud resources that have directly attached or
inherited tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``name`` is exactly ``tagValues/123``.
- ``kmsKey:key`` to find Google Cloud resources
encrypted with a customer-managed encryption key
whose name contains "key" as a word. This field is
whose name contains ``key`` as a word. This field is
deprecated. Please use the ``kmsKeys`` field to
retrieve Cloud KMS key information.
- ``kmsKeys:key`` to find Google Cloud resources
encrypted with customer-managed encryption keys whose
name contains the word "key".
name contains the word ``key``.
- ``relationships:instance-group-1`` to find Google
Cloud resources that have relationships with
"instance-group-1" in the related resource name.
``instance-group-1`` in the related resource name.
- ``relationships:INSTANCE_TO_INSTANCEGROUP`` to find
Compute Engine instances that have relationships of
type "INSTANCE_TO_INSTANCEGROUP".
type ``INSTANCE_TO_INSTANCEGROUP``.
- ``relationships.INSTANCE_TO_INSTANCEGROUP:instance-group-1``
to find Compute Engine instances that have
relationships with "instance-group-1" in the Compute
Engine instance group resource name, for relationship
type "INSTANCE_TO_INSTANCEGROUP".
relationships with ``instance-group-1`` in the
Compute Engine instance group resource name, for
relationship type ``INSTANCE_TO_INSTANCEGROUP``.
- ``state:ACTIVE`` to find Google Cloud resources whose
state contains "ACTIVE" as a word.
state contains ``ACTIVE`` as a word.
- ``NOT state:ACTIVE`` to find Google Cloud resources
whose state doesn't contain "ACTIVE" as a word.
whose state doesn't contain ``ACTIVE`` as a word.
- ``createTime<1609459200`` to find Google Cloud
resources that were created before "2021-01-01
00:00:00 UTC". 1609459200 is the epoch timestamp of
"2021-01-01 00:00:00 UTC" in seconds.
resources that were created before
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
seconds.
- ``updateTime>1609459200`` to find Google Cloud
resources that were updated after "2021-01-01
00:00:00 UTC". 1609459200 is the epoch timestamp of
"2021-01-01 00:00:00 UTC" in seconds.
resources that were updated after
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
seconds.
- ``Important`` to find Google Cloud resources that
contain "Important" as a word in any of the
contain ``Important`` as a word in any of the
searchable fields.
- ``Impor*`` to find Google Cloud resources that
contain "Impor" as a prefix of any word in any of the
searchable fields.
contain ``Impor`` as a prefix of any word in any of
the searchable fields.
- ``Important location:(us-west1 OR global)`` to find
Google Cloud resources that contain "Important" as a
word in any of the searchable fields and are also
located in the "us-west1" region or the "global"
Google Cloud resources that contain ``Important`` as
a word in any of the searchable fields and are also
located in the ``us-west1`` region or the ``global``
location.
This corresponds to the ``query`` field
Expand Down Expand Up @@ -1880,8 +1911,8 @@ async def query_assets(
metadata: Sequence[Tuple[str, str]] = (),
) -> asset_service.QueryAssetsResponse:
r"""Issue a job that queries assets using a SQL statement compatible
with `BigQuery Standard
SQL <http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql>`__.
with `BigQuery
SQL <https://cloud.google.com/bigquery/docs/introduction-sql>`__.
If the query execution finishes within timeout and there's no
pagination, the full query results will be returned in the
Expand All @@ -1892,9 +1923,9 @@ async def query_assets(
``QueryAssets`` call.
Note, the query result has approximately 10 GB limitation
enforced by BigQuery
https://cloud.google.com/bigquery/docs/best-practices-performance-output,
queries return larger results will result in errors.
enforced by
`BigQuery <https://cloud.google.com/bigquery/docs/best-practices-performance-output>`__.
Queries return larger results will result in errors.
.. code-block:: python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1476,62 +1476,93 @@ def sample_search_all_resources():
Examples:
- ``name:Important`` to find Google Cloud resources
whose name contains "Important" as a word.
whose name contains ``Important`` as a word.
- ``name=Important`` to find the Google Cloud resource
whose name is exactly "Important".
whose name is exactly ``Important``.
- ``displayName:Impor*`` to find Google Cloud resources
whose display name contains "Impor" as a prefix of
whose display name contains ``Impor`` as a prefix of
any word in the field.
- ``location:us-west*`` to find Google Cloud resources
whose location contains both "us" and "west" as
whose location contains both ``us`` and ``west`` as
prefixes.
- ``labels:prod`` to find Google Cloud resources whose
labels contain "prod" as a key or value.
labels contain ``prod`` as a key or value.
- ``labels.env:prod`` to find Google Cloud resources
that have a label "env" and its value is "prod".
that have a label ``env`` and its value is ``prod``.
- ``labels.env:*`` to find Google Cloud resources that
have a label "env".
have a label ``env``.
- ``tagKeys:env`` to find Google Cloud resources that
have directly attached tags where the
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
.\ ``namespacedName`` contains ``env``.
- ``tagValues:prod*`` to find Google Cloud resources
that have directly attached tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``namespacedName`` contains a word prefixed by
``prod``.
- ``tagValueIds=tagValues/123`` to find Google Cloud
resources that have directly attached tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``name`` is exactly ``tagValues/123``.
- ``effectiveTagKeys:env`` to find Google Cloud
resources that have directly attached or inherited
tags where the
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
.\ ``namespacedName`` contains ``env``.
- ``effectiveTagValues:prod*`` to find Google Cloud
resources that have directly attached or inherited
tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``namespacedName`` contains a word prefixed by
``prod``.
- ``effectiveTagValueIds=tagValues/123`` to find Google
Cloud resources that have directly attached or
inherited tags where the
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
.\ ``name`` is exactly ``tagValues/123``.
- ``kmsKey:key`` to find Google Cloud resources
encrypted with a customer-managed encryption key
whose name contains "key" as a word. This field is
whose name contains ``key`` as a word. This field is
deprecated. Please use the ``kmsKeys`` field to
retrieve Cloud KMS key information.
- ``kmsKeys:key`` to find Google Cloud resources
encrypted with customer-managed encryption keys whose
name contains the word "key".
name contains the word ``key``.
- ``relationships:instance-group-1`` to find Google
Cloud resources that have relationships with
"instance-group-1" in the related resource name.
``instance-group-1`` in the related resource name.
- ``relationships:INSTANCE_TO_INSTANCEGROUP`` to find
Compute Engine instances that have relationships of
type "INSTANCE_TO_INSTANCEGROUP".
type ``INSTANCE_TO_INSTANCEGROUP``.
- ``relationships.INSTANCE_TO_INSTANCEGROUP:instance-group-1``
to find Compute Engine instances that have
relationships with "instance-group-1" in the Compute
Engine instance group resource name, for relationship
type "INSTANCE_TO_INSTANCEGROUP".
relationships with ``instance-group-1`` in the
Compute Engine instance group resource name, for
relationship type ``INSTANCE_TO_INSTANCEGROUP``.
- ``state:ACTIVE`` to find Google Cloud resources whose
state contains "ACTIVE" as a word.
state contains ``ACTIVE`` as a word.
- ``NOT state:ACTIVE`` to find Google Cloud resources
whose state doesn't contain "ACTIVE" as a word.
whose state doesn't contain ``ACTIVE`` as a word.
- ``createTime<1609459200`` to find Google Cloud
resources that were created before "2021-01-01
00:00:00 UTC". 1609459200 is the epoch timestamp of
"2021-01-01 00:00:00 UTC" in seconds.
resources that were created before
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
seconds.
- ``updateTime>1609459200`` to find Google Cloud
resources that were updated after "2021-01-01
00:00:00 UTC". 1609459200 is the epoch timestamp of
"2021-01-01 00:00:00 UTC" in seconds.
resources that were updated after
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
seconds.
- ``Important`` to find Google Cloud resources that
contain "Important" as a word in any of the
contain ``Important`` as a word in any of the
searchable fields.
- ``Impor*`` to find Google Cloud resources that
contain "Impor" as a prefix of any word in any of the
searchable fields.
contain ``Impor`` as a prefix of any word in any of
the searchable fields.
- ``Important location:(us-west1 OR global)`` to find
Google Cloud resources that contain "Important" as a
word in any of the searchable fields and are also
located in the "us-west1" region or the "global"
Google Cloud resources that contain ``Important`` as
a word in any of the searchable fields and are also
located in the ``us-west1`` region or the ``global``
location.
This corresponds to the ``query`` field
Expand Down Expand Up @@ -2123,8 +2154,8 @@ def query_assets(
metadata: Sequence[Tuple[str, str]] = (),
) -> asset_service.QueryAssetsResponse:
r"""Issue a job that queries assets using a SQL statement compatible
with `BigQuery Standard
SQL <http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql>`__.
with `BigQuery
SQL <https://cloud.google.com/bigquery/docs/introduction-sql>`__.
If the query execution finishes within timeout and there's no
pagination, the full query results will be returned in the
Expand All @@ -2135,9 +2166,9 @@ def query_assets(
``QueryAssets`` call.
Note, the query result has approximately 10 GB limitation
enforced by BigQuery
https://cloud.google.com/bigquery/docs/best-practices-performance-output,
queries return larger results will result in errors.
enforced by
`BigQuery <https://cloud.google.com/bigquery/docs/best-practices-performance-output>`__.
Queries return larger results will result in errors.
.. code-block:: python
Expand Down
Loading

0 comments on commit b947b2c

Please sign in to comment.