GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Release of relationships in v1, Add content type Relationship t… · googleapis/python-asset@93c92c1

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

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • google/cloud
    • asset_v1
      • __init__.py
      • types
        • __init__.py
        • asset_service.py
        • assets.py
    • asset
      • __init__.py
  • scripts
    • fixup_asset_v1_keywords.py
  • tests/unit/gapic/asset_v1
    • test_asset_service.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎google/cloud/asset/__init__.py‎

Copy file name to clipboardExpand all lines: google/cloud/asset/__init__.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisResult
6868
from google.cloud.asset_v1.types.assets import IamPolicyAnalysisState
6969
from google.cloud.asset_v1.types.assets import IamPolicySearchResult
70+
from google.cloud.asset_v1.types.assets import RelatedAsset
71+
from google.cloud.asset_v1.types.assets import RelatedAssets
72+
from google.cloud.asset_v1.types.assets import RelationshipAttributes
7073
from google.cloud.asset_v1.types.assets import Resource
7174
from google.cloud.asset_v1.types.assets import ResourceSearchResult
7275
from google.cloud.asset_v1.types.assets import TemporalAsset
@@ -120,6 +123,9 @@
120123
"IamPolicyAnalysisResult",
121124
"IamPolicyAnalysisState",
122125
"IamPolicySearchResult",
126+
"RelatedAsset",
127+
"RelatedAssets",
128+
"RelationshipAttributes",
123129
"Resource",
124130
"ResourceSearchResult",
125131
"TemporalAsset",
Collapse file

‎google/cloud/asset_v1/__init__.py‎

Copy file name to clipboardExpand all lines: google/cloud/asset_v1/__init__.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
from .types.assets import IamPolicyAnalysisResult
6262
from .types.assets import IamPolicyAnalysisState
6363
from .types.assets import IamPolicySearchResult
64+
from .types.assets import RelatedAsset
65+
from .types.assets import RelatedAssets
66+
from .types.assets import RelationshipAttributes
6467
from .types.assets import Resource
6568
from .types.assets import ResourceSearchResult
6669
from .types.assets import TemporalAsset
@@ -109,6 +112,9 @@
109112
"OutputResult",
110113
"PartitionSpec",
111114
"PubsubDestination",
115+
"RelatedAsset",
116+
"RelatedAssets",
117+
"RelationshipAttributes",
112118
"Resource",
113119
"ResourceSearchResult",
114120
"SearchAllIamPoliciesRequest",
Collapse file

‎google/cloud/asset_v1/types/__init__.py‎

Copy file name to clipboardExpand all lines: google/cloud/asset_v1/types/__init__.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@
6060
IamPolicyAnalysisResult,
6161
IamPolicyAnalysisState,
6262
IamPolicySearchResult,
63+
RelatedAsset,
64+
RelatedAssets,
65+
RelationshipAttributes,
6366
Resource,
6467
ResourceSearchResult,
6568
TemporalAsset,
@@ -112,6 +115,9 @@
112115
"IamPolicyAnalysisResult",
113116
"IamPolicyAnalysisState",
114117
"IamPolicySearchResult",
118+
"RelatedAsset",
119+
"RelatedAssets",
120+
"RelationshipAttributes",
115121
"Resource",
116122
"ResourceSearchResult",
117123
"TemporalAsset",
Collapse file

‎google/cloud/asset_v1/types/asset_service.py‎

Copy file name to clipboardExpand all lines: google/cloud/asset_v1/types/asset_service.py
+77-1Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class ContentType(proto.Enum):
7676
ORG_POLICY = 4
7777
ACCESS_POLICY = 5
7878
OS_INVENTORY = 6
79+
RELATIONSHIP = 7
7980

8081

8182
class AnalyzeIamPolicyLongrunningMetadata(proto.Message):
@@ -84,7 +85,8 @@ class AnalyzeIamPolicyLongrunningMetadata(proto.Message):
8485
8586
Attributes:
8687
create_time (google.protobuf.timestamp_pb2.Timestamp):
87-
The time the operation was created.
88+
Output only. The time the operation was
89+
created.
8890
"""
8991

9092
create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,)
@@ -138,13 +140,31 @@ class ExportAssetsRequest(proto.Message):
138140
output_config (google.cloud.asset_v1.types.OutputConfig):
139141
Required. Output configuration indicating
140142
where the results will be output to.
143+
relationship_types (Sequence[str]):
144+
A list of relationship types to export, for example:
145+
``INSTANCE_TO_INSTANCEGROUP``. This field should only be
146+
specified if content_type=RELATIONSHIP.
147+
148+
- If specified: it snapshots specified relationships. It
149+
returns an error if any of the [relationship_types]
150+
doesn't belong to the supported relationship types of the
151+
[asset_types] or if any of the [asset_types] doesn't
152+
belong to the source types of the [relationship_types].
153+
- Otherwise: it snapshots the supported relationships for
154+
all [asset_types] or returns an error if any of the
155+
[asset_types] has no relationship support. An unspecified
156+
asset types field means all supported asset_types. See
157+
`Introduction to Cloud Asset
158+
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
159+
for all supported asset types and relationship types.
141160
"""
142161

143162
parent = proto.Field(proto.STRING, number=1,)
144163
read_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,)
145164
asset_types = proto.RepeatedField(proto.STRING, number=3,)
146165
content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",)
147166
output_config = proto.Field(proto.MESSAGE, number=5, message="OutputConfig",)
167+
relationship_types = proto.RepeatedField(proto.STRING, number=6,)
148168

149169

150170
class ExportAssetsResponse(proto.Message):
@@ -228,6 +248,23 @@ class ListAssetsRequest(proto.Message):
228248
``ListAssetsRequest``. It is a continuation of a prior
229249
``ListAssets`` call, and the API should return the next page
230250
of assets.
251+
relationship_types (Sequence[str]):
252+
A list of relationship types to output, for example:
253+
``INSTANCE_TO_INSTANCEGROUP``. This field should only be
254+
specified if content_type=RELATIONSHIP.
255+
256+
- If specified: it snapshots specified relationships. It
257+
returns an error if any of the [relationship_types]
258+
doesn't belong to the supported relationship types of the
259+
[asset_types] or if any of the [asset_types] doesn't
260+
belong to the source types of the [relationship_types].
261+
- Otherwise: it snapshots the supported relationships for
262+
all [asset_types] or returns an error if any of the
263+
[asset_types] has no relationship support. An unspecified
264+
asset types field means all supported asset_types. See
265+
`Introduction to Cloud Asset
266+
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
267+
for all supported asset types and relationship types.
231268
"""
232269

233270
parent = proto.Field(proto.STRING, number=1,)
@@ -236,6 +273,7 @@ class ListAssetsRequest(proto.Message):
236273
content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",)
237274
page_size = proto.Field(proto.INT32, number=5,)
238275
page_token = proto.Field(proto.STRING, number=6,)
276+
relationship_types = proto.RepeatedField(proto.STRING, number=7,)
239277

240278

241279
class ListAssetsResponse(proto.Message):
@@ -290,6 +328,23 @@ class BatchGetAssetsHistoryRequest(proto.Message):
290328
not set, the snapshot of the assets at end_time will be
291329
returned. The returned results contain all temporal assets
292330
whose time window overlap with read_time_window.
331+
relationship_types (Sequence[str]):
332+
Optional. A list of relationship types to output, for
333+
example: ``INSTANCE_TO_INSTANCEGROUP``. This field should
334+
only be specified if content_type=RELATIONSHIP.
335+
336+
- If specified: it outputs specified relationships' history
337+
on the [asset_names]. It returns an error if any of the
338+
[relationship_types] doesn't belong to the supported
339+
relationship types of the [asset_names] or if any of the
340+
[asset_names]'s types doesn't belong to the source types
341+
of the [relationship_types].
342+
- Otherwise: it outputs the supported relationships'
343+
history on the [asset_names] or returns an error if any
344+
of the [asset_names]'s types has no relationship support.
345+
See `Introduction to Cloud Asset
346+
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
347+
for all supported asset types and relationship types.
293348
"""
294349

295350
parent = proto.Field(proto.STRING, number=1,)
@@ -298,6 +353,7 @@ class BatchGetAssetsHistoryRequest(proto.Message):
298353
read_time_window = proto.Field(
299354
proto.MESSAGE, number=4, message=gca_assets.TimeWindow,
300355
)
356+
relationship_types = proto.RepeatedField(proto.STRING, number=5,)
301357

302358

303359
class BatchGetAssetsHistoryResponse(proto.Message):
@@ -675,6 +731,25 @@ class Feed(proto.Message):
675731
See our `user
676732
guide <https://cloud.google.com/asset-inventory/docs/monitoring-asset-changes-with-condition>`__
677733
for detailed instructions.
734+
relationship_types (Sequence[str]):
735+
A list of relationship types to output, for example:
736+
``INSTANCE_TO_INSTANCEGROUP``. This field should only be
737+
specified if content_type=RELATIONSHIP.
738+
739+
- If specified: it outputs specified relationship updates
740+
on the [asset_names] or the [asset_types]. It returns an
741+
error if any of the [relationship_types] doesn't belong
742+
to the supported relationship types of the [asset_names]
743+
or [asset_types], or any of the [asset_names] or the
744+
[asset_types] doesn't belong to the source types of the
745+
[relationship_types].
746+
- Otherwise: it outputs the supported relationships of the
747+
types of [asset_names] and [asset_types] or returns an
748+
error if any of the [asset_names] or the [asset_types]
749+
has no replationship support. See `Introduction to Cloud
750+
Asset
751+
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
752+
for all supported asset types and relationship types.
678753
"""
679754

680755
name = proto.Field(proto.STRING, number=1,)
@@ -685,6 +760,7 @@ class Feed(proto.Message):
685760
proto.MESSAGE, number=5, message="FeedOutputConfig",
686761
)
687762
condition = proto.Field(proto.MESSAGE, number=6, message=expr_pb2.Expr,)
763+
relationship_types = proto.RepeatedField(proto.STRING, number=7,)
688764

689765

690766
class SearchAllResourcesRequest(proto.Message):
Collapse file

‎google/cloud/asset_v1/types/assets.py‎

Copy file name to clipboardExpand all lines: google/cloud/asset_v1/types/assets.py
+90Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
"TimeWindow",
3434
"Asset",
3535
"Resource",
36+
"RelatedAssets",
37+
"RelationshipAttributes",
38+
"RelatedAsset",
3639
"ResourceSearchResult",
3740
"VersionedResource",
3841
"AttachedResource",
@@ -157,6 +160,10 @@ class Asset(proto.Message):
157160
`this
158161
topic <https://cloud.google.com/compute/docs/instances/os-inventory-management>`__
159162
for more information.
163+
related_assets (google.cloud.asset_v1.types.RelatedAssets):
164+
The related assets of the asset of one
165+
relationship type. One asset only represents one
166+
type of relationship.
160167
ancestors (Sequence[str]):
161168
The ancestry path of an asset in Google Cloud `resource
162169
hierarchy <https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy>`__,
@@ -199,6 +206,7 @@ class Asset(proto.Message):
199206
message=service_perimeter_pb2.ServicePerimeter,
200207
)
201208
os_inventory = proto.Field(proto.MESSAGE, number=12, message=Inventory,)
209+
related_assets = proto.Field(proto.MESSAGE, number=13, message="RelatedAssets",)
202210
ancestors = proto.RepeatedField(proto.STRING, number=10,)
203211

204212

@@ -259,6 +267,88 @@ class Resource(proto.Message):
259267
location = proto.Field(proto.STRING, number=8,)
260268

261269

270+
class RelatedAssets(proto.Message):
271+
r"""The detailed related assets with the ``relationship_type``.
272+
Attributes:
273+
relationship_attributes (google.cloud.asset_v1.types.RelationshipAttributes):
274+
The detailed relationship attributes.
275+
assets (Sequence[google.cloud.asset_v1.types.RelatedAsset]):
276+
The peer resources of the relationship.
277+
"""
278+
279+
relationship_attributes = proto.Field(
280+
proto.MESSAGE, number=1, message="RelationshipAttributes",
281+
)
282+
assets = proto.RepeatedField(proto.MESSAGE, number=2, message="RelatedAsset",)
283+
284+
285+
class RelationshipAttributes(proto.Message):
286+
r"""The relationship attributes which include ``type``,
287+
``source_resource_type``, ``target_resource_type`` and ``action``.
288+
289+
Attributes:
290+
type_ (str):
291+
The unique identifier of the relationship type. Example:
292+
``INSTANCE_TO_INSTANCEGROUP``
293+
source_resource_type (str):
294+
The source asset type. Example:
295+
``compute.googleapis.com/Instance``
296+
target_resource_type (str):
297+
The target asset type. Example:
298+
``compute.googleapis.com/Disk``
299+
action (str):
300+
The detail of the relationship, e.g. ``contains``,
301+
``attaches``
302+
"""
303+
304+
type_ = proto.Field(proto.STRING, number=4,)
305+
source_resource_type = proto.Field(proto.STRING, number=1,)
306+
target_resource_type = proto.Field(proto.STRING, number=2,)
307+
action = proto.Field(proto.STRING, number=3,)
308+
309+
310+
class RelatedAsset(proto.Message):
311+
r"""An asset identify in Google Cloud which contains its name, type and
312+
ancestors. An asset can be any resource in the Google Cloud
313+
`resource
314+
hierarchy <https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy>`__,
315+
a resource outside the Google Cloud resource hierarchy (such as
316+
Google Kubernetes Engine clusters and objects), or a policy (e.g.
317+
Cloud IAM policy). See `Supported asset
318+
types <https://cloud.google.com/asset-inventory/docs/supported-asset-types>`__
319+
for more information.
320+
321+
Attributes:
322+
asset (str):
323+
The full name of the asset. Example:
324+
``//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1``
325+
326+
See `Resource
327+
names <https://cloud.google.com/apis/design/resource_names#full_resource_name>`__
328+
for more information.
329+
asset_type (str):
330+
The type of the asset. Example:
331+
``compute.googleapis.com/Disk``
332+
333+
See `Supported asset
334+
types <https://cloud.google.com/asset-inventory/docs/supported-asset-types>`__
335+
for more information.
336+
ancestors (Sequence[str]):
337+
The ancestors of an asset in Google Cloud `resource
338+
hierarchy <https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy>`__,
339+
represented as a list of relative resource names. An
340+
ancestry path starts with the closest ancestor in the
341+
hierarchy and ends at root.
342+
343+
Example:
344+
``["projects/123456789", "folders/5432", "organizations/1234"]``
345+
"""
346+
347+
asset = proto.Field(proto.STRING, number=1,)
348+
asset_type = proto.Field(proto.STRING, number=2,)
349+
ancestors = proto.RepeatedField(proto.STRING, number=3,)
350+
351+
262352
class ResourceSearchResult(proto.Message):
263353
r"""A result of Resource Search, containing information of a
264354
cloud resource.
Collapse file

‎scripts/fixup_asset_v1_keywords.py‎

Copy file name to clipboardExpand all lines: scripts/fixup_asset_v1_keywords.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class assetCallTransformer(cst.CSTTransformer):
4242
'analyze_iam_policy': ('analysis_query', 'execution_timeout', ),
4343
'analyze_iam_policy_longrunning': ('analysis_query', 'output_config', ),
4444
'analyze_move': ('resource', 'destination_parent', 'view', ),
45-
'batch_get_assets_history': ('parent', 'asset_names', 'content_type', 'read_time_window', ),
45+
'batch_get_assets_history': ('parent', 'asset_names', 'content_type', 'read_time_window', 'relationship_types', ),
4646
'create_feed': ('parent', 'feed_id', 'feed', ),
4747
'delete_feed': ('name', ),
48-
'export_assets': ('parent', 'output_config', 'read_time', 'asset_types', 'content_type', ),
48+
'export_assets': ('parent', 'output_config', 'read_time', 'asset_types', 'content_type', 'relationship_types', ),
4949
'get_feed': ('name', ),
50-
'list_assets': ('parent', 'read_time', 'asset_types', 'content_type', 'page_size', 'page_token', ),
50+
'list_assets': ('parent', 'read_time', 'asset_types', 'content_type', 'page_size', 'page_token', 'relationship_types', ),
5151
'list_feeds': ('parent', ),
5252
'search_all_iam_policies': ('scope', 'query', 'page_size', 'page_token', 'asset_types', 'order_by', ),
5353
'search_all_resources': ('scope', 'query', 'asset_types', 'page_size', 'page_token', 'order_by', 'read_mask', ),

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.