Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 7e2b606

Browse files
feat: add support for directly attached and effective tags (#589)
* 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: https://github.com/googleapis/googleapis-gen/commit/df4f7ba41a807a193b48afdba8d4aef35636875a 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>
1 parent 6374962 commit 7e2b606

File tree

9 files changed

+424
-165
lines changed

9 files changed

+424
-165
lines changed

google/cloud/asset/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
from google.cloud.asset_v1.types.assets import Asset
104104
from google.cloud.asset_v1.types.assets import AttachedResource
105105
from google.cloud.asset_v1.types.assets import ConditionEvaluation
106+
from google.cloud.asset_v1.types.assets import EffectiveTagDetails
106107
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisResult
107108
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisState
108109
from google.cloud.asset_v1.types.assets import IamPolicySearchResult
@@ -113,6 +114,7 @@
113114
from google.cloud.asset_v1.types.assets import RelationshipAttributes
114115
from google.cloud.asset_v1.types.assets import Resource
115116
from google.cloud.asset_v1.types.assets import ResourceSearchResult
117+
from google.cloud.asset_v1.types.assets import Tag
116118
from google.cloud.asset_v1.types.assets import TemporalAsset
117119
from google.cloud.asset_v1.types.assets import TimeWindow
118120
from google.cloud.asset_v1.types.assets import VersionedResource
@@ -184,6 +186,7 @@
184186
"Asset",
185187
"AttachedResource",
186188
"ConditionEvaluation",
189+
"EffectiveTagDetails",
187190
"IamPolicyAnalysisResult",
188191
"IamPolicyAnalysisState",
189192
"IamPolicySearchResult",
@@ -194,6 +197,7 @@
194197
"RelationshipAttributes",
195198
"Resource",
196199
"ResourceSearchResult",
200+
"Tag",
197201
"TemporalAsset",
198202
"TimeWindow",
199203
"VersionedResource",

google/cloud/asset_v1/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
from .types.assets import Asset
8686
from .types.assets import AttachedResource
8787
from .types.assets import ConditionEvaluation
88+
from .types.assets import EffectiveTagDetails
8889
from .types.assets import IamPolicyAnalysisResult
8990
from .types.assets import IamPolicyAnalysisState
9091
from .types.assets import IamPolicySearchResult
@@ -95,6 +96,7 @@
9596
from .types.assets import RelationshipAttributes
9697
from .types.assets import Resource
9798
from .types.assets import ResourceSearchResult
99+
from .types.assets import Tag
98100
from .types.assets import TemporalAsset
99101
from .types.assets import TimeWindow
100102
from .types.assets import VersionedResource
@@ -130,6 +132,7 @@
130132
"CreateSavedQueryRequest",
131133
"DeleteFeedRequest",
132134
"DeleteSavedQueryRequest",
135+
"EffectiveTagDetails",
133136
"ExportAssetsRequest",
134137
"ExportAssetsResponse",
135138
"Feed",
@@ -174,6 +177,7 @@
174177
"SearchAllResourcesResponse",
175178
"TableFieldSchema",
176179
"TableSchema",
180+
"Tag",
177181
"TemporalAsset",
178182
"TimeWindow",
179183
"UpdateFeedRequest",

google/cloud/asset_v1/services/asset_service/async_client.py

+64-33
Original file line numberDiff line numberDiff line change
@@ -1211,62 +1211,93 @@ async def sample_search_all_resources():
12111211
Examples:
12121212
12131213
- ``name:Important`` to find Google Cloud resources
1214-
whose name contains "Important" as a word.
1214+
whose name contains ``Important`` as a word.
12151215
- ``name=Important`` to find the Google Cloud resource
1216-
whose name is exactly "Important".
1216+
whose name is exactly ``Important``.
12171217
- ``displayName:Impor*`` to find Google Cloud resources
1218-
whose display name contains "Impor" as a prefix of
1218+
whose display name contains ``Impor`` as a prefix of
12191219
any word in the field.
12201220
- ``location:us-west*`` to find Google Cloud resources
1221-
whose location contains both "us" and "west" as
1221+
whose location contains both ``us`` and ``west`` as
12221222
prefixes.
12231223
- ``labels:prod`` to find Google Cloud resources whose
1224-
labels contain "prod" as a key or value.
1224+
labels contain ``prod`` as a key or value.
12251225
- ``labels.env:prod`` to find Google Cloud resources
1226-
that have a label "env" and its value is "prod".
1226+
that have a label ``env`` and its value is ``prod``.
12271227
- ``labels.env:*`` to find Google Cloud resources that
1228-
have a label "env".
1228+
have a label ``env``.
1229+
- ``tagKeys:env`` to find Google Cloud resources that
1230+
have directly attached tags where the
1231+
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
1232+
.\ ``namespacedName`` contains ``env``.
1233+
- ``tagValues:prod*`` to find Google Cloud resources
1234+
that have directly attached tags where the
1235+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1236+
.\ ``namespacedName`` contains a word prefixed by
1237+
``prod``.
1238+
- ``tagValueIds=tagValues/123`` to find Google Cloud
1239+
resources that have directly attached tags where the
1240+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1241+
.\ ``name`` is exactly ``tagValues/123``.
1242+
- ``effectiveTagKeys:env`` to find Google Cloud
1243+
resources that have directly attached or inherited
1244+
tags where the
1245+
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
1246+
.\ ``namespacedName`` contains ``env``.
1247+
- ``effectiveTagValues:prod*`` to find Google Cloud
1248+
resources that have directly attached or inherited
1249+
tags where the
1250+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1251+
.\ ``namespacedName`` contains a word prefixed by
1252+
``prod``.
1253+
- ``effectiveTagValueIds=tagValues/123`` to find Google
1254+
Cloud resources that have directly attached or
1255+
inherited tags where the
1256+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1257+
.\ ``name`` is exactly ``tagValues/123``.
12291258
- ``kmsKey:key`` to find Google Cloud resources
12301259
encrypted with a customer-managed encryption key
1231-
whose name contains "key" as a word. This field is
1260+
whose name contains ``key`` as a word. This field is
12321261
deprecated. Please use the ``kmsKeys`` field to
12331262
retrieve Cloud KMS key information.
12341263
- ``kmsKeys:key`` to find Google Cloud resources
12351264
encrypted with customer-managed encryption keys whose
1236-
name contains the word "key".
1265+
name contains the word ``key``.
12371266
- ``relationships:instance-group-1`` to find Google
12381267
Cloud resources that have relationships with
1239-
"instance-group-1" in the related resource name.
1268+
``instance-group-1`` in the related resource name.
12401269
- ``relationships:INSTANCE_TO_INSTANCEGROUP`` to find
12411270
Compute Engine instances that have relationships of
1242-
type "INSTANCE_TO_INSTANCEGROUP".
1271+
type ``INSTANCE_TO_INSTANCEGROUP``.
12431272
- ``relationships.INSTANCE_TO_INSTANCEGROUP:instance-group-1``
12441273
to find Compute Engine instances that have
1245-
relationships with "instance-group-1" in the Compute
1246-
Engine instance group resource name, for relationship
1247-
type "INSTANCE_TO_INSTANCEGROUP".
1274+
relationships with ``instance-group-1`` in the
1275+
Compute Engine instance group resource name, for
1276+
relationship type ``INSTANCE_TO_INSTANCEGROUP``.
12481277
- ``state:ACTIVE`` to find Google Cloud resources whose
1249-
state contains "ACTIVE" as a word.
1278+
state contains ``ACTIVE`` as a word.
12501279
- ``NOT state:ACTIVE`` to find Google Cloud resources
1251-
whose state doesn't contain "ACTIVE" as a word.
1280+
whose state doesn't contain ``ACTIVE`` as a word.
12521281
- ``createTime<1609459200`` to find Google Cloud
1253-
resources that were created before "2021-01-01
1254-
00:00:00 UTC". 1609459200 is the epoch timestamp of
1255-
"2021-01-01 00:00:00 UTC" in seconds.
1282+
resources that were created before
1283+
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
1284+
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
1285+
seconds.
12561286
- ``updateTime>1609459200`` to find Google Cloud
1257-
resources that were updated after "2021-01-01
1258-
00:00:00 UTC". 1609459200 is the epoch timestamp of
1259-
"2021-01-01 00:00:00 UTC" in seconds.
1287+
resources that were updated after
1288+
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
1289+
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
1290+
seconds.
12601291
- ``Important`` to find Google Cloud resources that
1261-
contain "Important" as a word in any of the
1292+
contain ``Important`` as a word in any of the
12621293
searchable fields.
12631294
- ``Impor*`` to find Google Cloud resources that
1264-
contain "Impor" as a prefix of any word in any of the
1265-
searchable fields.
1295+
contain ``Impor`` as a prefix of any word in any of
1296+
the searchable fields.
12661297
- ``Important location:(us-west1 OR global)`` to find
1267-
Google Cloud resources that contain "Important" as a
1268-
word in any of the searchable fields and are also
1269-
located in the "us-west1" region or the "global"
1298+
Google Cloud resources that contain ``Important`` as
1299+
a word in any of the searchable fields and are also
1300+
located in the ``us-west1`` region or the ``global``
12701301
location.
12711302
12721303
This corresponds to the ``query`` field
@@ -1880,8 +1911,8 @@ async def query_assets(
18801911
metadata: Sequence[Tuple[str, str]] = (),
18811912
) -> asset_service.QueryAssetsResponse:
18821913
r"""Issue a job that queries assets using a SQL statement compatible
1883-
with `BigQuery Standard
1884-
SQL <http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql>`__.
1914+
with `BigQuery
1915+
SQL <https://cloud.google.com/bigquery/docs/introduction-sql>`__.
18851916
18861917
If the query execution finishes within timeout and there's no
18871918
pagination, the full query results will be returned in the
@@ -1892,9 +1923,9 @@ async def query_assets(
18921923
``QueryAssets`` call.
18931924
18941925
Note, the query result has approximately 10 GB limitation
1895-
enforced by BigQuery
1896-
https://cloud.google.com/bigquery/docs/best-practices-performance-output,
1897-
queries return larger results will result in errors.
1926+
enforced by
1927+
`BigQuery <https://cloud.google.com/bigquery/docs/best-practices-performance-output>`__.
1928+
Queries return larger results will result in errors.
18981929
18991930
.. code-block:: python
19001931

google/cloud/asset_v1/services/asset_service/client.py

+64-33
Original file line numberDiff line numberDiff line change
@@ -1476,62 +1476,93 @@ def sample_search_all_resources():
14761476
Examples:
14771477
14781478
- ``name:Important`` to find Google Cloud resources
1479-
whose name contains "Important" as a word.
1479+
whose name contains ``Important`` as a word.
14801480
- ``name=Important`` to find the Google Cloud resource
1481-
whose name is exactly "Important".
1481+
whose name is exactly ``Important``.
14821482
- ``displayName:Impor*`` to find Google Cloud resources
1483-
whose display name contains "Impor" as a prefix of
1483+
whose display name contains ``Impor`` as a prefix of
14841484
any word in the field.
14851485
- ``location:us-west*`` to find Google Cloud resources
1486-
whose location contains both "us" and "west" as
1486+
whose location contains both ``us`` and ``west`` as
14871487
prefixes.
14881488
- ``labels:prod`` to find Google Cloud resources whose
1489-
labels contain "prod" as a key or value.
1489+
labels contain ``prod`` as a key or value.
14901490
- ``labels.env:prod`` to find Google Cloud resources
1491-
that have a label "env" and its value is "prod".
1491+
that have a label ``env`` and its value is ``prod``.
14921492
- ``labels.env:*`` to find Google Cloud resources that
1493-
have a label "env".
1493+
have a label ``env``.
1494+
- ``tagKeys:env`` to find Google Cloud resources that
1495+
have directly attached tags where the
1496+
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
1497+
.\ ``namespacedName`` contains ``env``.
1498+
- ``tagValues:prod*`` to find Google Cloud resources
1499+
that have directly attached tags where the
1500+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1501+
.\ ``namespacedName`` contains a word prefixed by
1502+
``prod``.
1503+
- ``tagValueIds=tagValues/123`` to find Google Cloud
1504+
resources that have directly attached tags where the
1505+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1506+
.\ ``name`` is exactly ``tagValues/123``.
1507+
- ``effectiveTagKeys:env`` to find Google Cloud
1508+
resources that have directly attached or inherited
1509+
tags where the
1510+
```TagKey`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagKeys#resource:-tagkey>`__
1511+
.\ ``namespacedName`` contains ``env``.
1512+
- ``effectiveTagValues:prod*`` to find Google Cloud
1513+
resources that have directly attached or inherited
1514+
tags where the
1515+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1516+
.\ ``namespacedName`` contains a word prefixed by
1517+
``prod``.
1518+
- ``effectiveTagValueIds=tagValues/123`` to find Google
1519+
Cloud resources that have directly attached or
1520+
inherited tags where the
1521+
```TagValue`` <https://cloud.google.com/resource-manager/reference/rest/v3/tagValues#resource:-tagvalue>`__
1522+
.\ ``name`` is exactly ``tagValues/123``.
14941523
- ``kmsKey:key`` to find Google Cloud resources
14951524
encrypted with a customer-managed encryption key
1496-
whose name contains "key" as a word. This field is
1525+
whose name contains ``key`` as a word. This field is
14971526
deprecated. Please use the ``kmsKeys`` field to
14981527
retrieve Cloud KMS key information.
14991528
- ``kmsKeys:key`` to find Google Cloud resources
15001529
encrypted with customer-managed encryption keys whose
1501-
name contains the word "key".
1530+
name contains the word ``key``.
15021531
- ``relationships:instance-group-1`` to find Google
15031532
Cloud resources that have relationships with
1504-
"instance-group-1" in the related resource name.
1533+
``instance-group-1`` in the related resource name.
15051534
- ``relationships:INSTANCE_TO_INSTANCEGROUP`` to find
15061535
Compute Engine instances that have relationships of
1507-
type "INSTANCE_TO_INSTANCEGROUP".
1536+
type ``INSTANCE_TO_INSTANCEGROUP``.
15081537
- ``relationships.INSTANCE_TO_INSTANCEGROUP:instance-group-1``
15091538
to find Compute Engine instances that have
1510-
relationships with "instance-group-1" in the Compute
1511-
Engine instance group resource name, for relationship
1512-
type "INSTANCE_TO_INSTANCEGROUP".
1539+
relationships with ``instance-group-1`` in the
1540+
Compute Engine instance group resource name, for
1541+
relationship type ``INSTANCE_TO_INSTANCEGROUP``.
15131542
- ``state:ACTIVE`` to find Google Cloud resources whose
1514-
state contains "ACTIVE" as a word.
1543+
state contains ``ACTIVE`` as a word.
15151544
- ``NOT state:ACTIVE`` to find Google Cloud resources
1516-
whose state doesn't contain "ACTIVE" as a word.
1545+
whose state doesn't contain ``ACTIVE`` as a word.
15171546
- ``createTime<1609459200`` to find Google Cloud
1518-
resources that were created before "2021-01-01
1519-
00:00:00 UTC". 1609459200 is the epoch timestamp of
1520-
"2021-01-01 00:00:00 UTC" in seconds.
1547+
resources that were created before
1548+
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
1549+
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
1550+
seconds.
15211551
- ``updateTime>1609459200`` to find Google Cloud
1522-
resources that were updated after "2021-01-01
1523-
00:00:00 UTC". 1609459200 is the epoch timestamp of
1524-
"2021-01-01 00:00:00 UTC" in seconds.
1552+
resources that were updated after
1553+
``2021-01-01 00:00:00 UTC``. ``1609459200`` is the
1554+
epoch timestamp of ``2021-01-01 00:00:00 UTC`` in
1555+
seconds.
15251556
- ``Important`` to find Google Cloud resources that
1526-
contain "Important" as a word in any of the
1557+
contain ``Important`` as a word in any of the
15271558
searchable fields.
15281559
- ``Impor*`` to find Google Cloud resources that
1529-
contain "Impor" as a prefix of any word in any of the
1530-
searchable fields.
1560+
contain ``Impor`` as a prefix of any word in any of
1561+
the searchable fields.
15311562
- ``Important location:(us-west1 OR global)`` to find
1532-
Google Cloud resources that contain "Important" as a
1533-
word in any of the searchable fields and are also
1534-
located in the "us-west1" region or the "global"
1563+
Google Cloud resources that contain ``Important`` as
1564+
a word in any of the searchable fields and are also
1565+
located in the ``us-west1`` region or the ``global``
15351566
location.
15361567
15371568
This corresponds to the ``query`` field
@@ -2123,8 +2154,8 @@ def query_assets(
21232154
metadata: Sequence[Tuple[str, str]] = (),
21242155
) -> asset_service.QueryAssetsResponse:
21252156
r"""Issue a job that queries assets using a SQL statement compatible
2126-
with `BigQuery Standard
2127-
SQL <http://cloud/bigquery/docs/reference/standard-sql/enabling-standard-sql>`__.
2157+
with `BigQuery
2158+
SQL <https://cloud.google.com/bigquery/docs/introduction-sql>`__.
21282159
21292160
If the query execution finishes within timeout and there's no
21302161
pagination, the full query results will be returned in the
@@ -2135,9 +2166,9 @@ def query_assets(
21352166
``QueryAssets`` call.
21362167
21372168
Note, the query result has approximately 10 GB limitation
2138-
enforced by BigQuery
2139-
https://cloud.google.com/bigquery/docs/best-practices-performance-output,
2140-
queries return larger results will result in errors.
2169+
enforced by
2170+
`BigQuery <https://cloud.google.com/bigquery/docs/best-practices-performance-output>`__.
2171+
Queries return larger results will result in errors.
21412172
21422173
.. code-block:: python
21432174

0 commit comments

Comments
 (0)