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 treeExpand file treeCollapse file tree Open diff view settings tests/unit/gapic/asset_v1
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: google/cloud/asset/__init__.py +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 67 | 67 | from google.cloud.asset_v1.types.assets import IamPolicyAnalysisResult | 68 | 68 | from google.cloud.asset_v1.types.assets import IamPolicyAnalysisState | 69 | 69 | 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 | 70 | 73 | from google.cloud.asset_v1.types.assets import Resource | 71 | 74 | from google.cloud.asset_v1.types.assets import ResourceSearchResult | 72 | 75 | from google.cloud.asset_v1.types.assets import TemporalAsset | | 120 | 123 | "IamPolicyAnalysisResult", | 121 | 124 | "IamPolicyAnalysisState", | 122 | 125 | "IamPolicySearchResult", | | 126 | + "RelatedAsset", | | 127 | + "RelatedAssets", | | 128 | + "RelationshipAttributes", | 123 | 129 | "Resource", | 124 | 130 | "ResourceSearchResult", | 125 | 131 | "TemporalAsset", | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/asset_v1/__init__.py +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 61 | 61 | from .types.assets import IamPolicyAnalysisResult | 62 | 62 | from .types.assets import IamPolicyAnalysisState | 63 | 63 | from .types.assets import IamPolicySearchResult | | 64 | +from .types.assets import RelatedAsset | | 65 | +from .types.assets import RelatedAssets | | 66 | +from .types.assets import RelationshipAttributes | 64 | 67 | from .types.assets import Resource | 65 | 68 | from .types.assets import ResourceSearchResult | 66 | 69 | from .types.assets import TemporalAsset | | 109 | 112 | "OutputResult", | 110 | 113 | "PartitionSpec", | 111 | 114 | "PubsubDestination", | | 115 | + "RelatedAsset", | | 116 | + "RelatedAssets", | | 117 | + "RelationshipAttributes", | 112 | 118 | "Resource", | 113 | 119 | "ResourceSearchResult", | 114 | 120 | "SearchAllIamPoliciesRequest", | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/asset_v1/types/__init__.py +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 60 | 60 | IamPolicyAnalysisResult, | 61 | 61 | IamPolicyAnalysisState, | 62 | 62 | IamPolicySearchResult, | | 63 | + RelatedAsset, | | 64 | + RelatedAssets, | | 65 | + RelationshipAttributes, | 63 | 66 | Resource, | 64 | 67 | ResourceSearchResult, | 65 | 68 | TemporalAsset, | | 112 | 115 | "IamPolicyAnalysisResult", | 113 | 116 | "IamPolicyAnalysisState", | 114 | 117 | "IamPolicySearchResult", | | 118 | + "RelatedAsset", | | 119 | + "RelatedAssets", | | 120 | + "RelationshipAttributes", | 115 | 121 | "Resource", | 116 | 122 | "ResourceSearchResult", | 117 | 123 | "TemporalAsset", | |
Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -76,6 +76,7 @@ class ContentType(proto.Enum): | 76 | 76 | ORG_POLICY = 4 | 77 | 77 | ACCESS_POLICY = 5 | 78 | 78 | OS_INVENTORY = 6 | | 79 | + RELATIONSHIP = 7 | 79 | 80 |
| 80 | 81 |
| 81 | 82 | class AnalyzeIamPolicyLongrunningMetadata(proto.Message): | @@ -84,7 +85,8 @@ class AnalyzeIamPolicyLongrunningMetadata(proto.Message): | 84 | 85 |
| 85 | 86 | Attributes: | 86 | 87 | create_time (google.protobuf.timestamp_pb2.Timestamp): | 87 | | - The time the operation was created. | | 88 | + Output only. The time the operation was | | 89 | + created. | 88 | 90 | """ | 89 | 91 |
| 90 | 92 | create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) | @@ -138,13 +140,31 @@ class ExportAssetsRequest(proto.Message): | 138 | 140 | output_config (google.cloud.asset_v1.types.OutputConfig): | 139 | 141 | Required. Output configuration indicating | 140 | 142 | 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. | 141 | 160 | """ | 142 | 161 |
| 143 | 162 | parent = proto.Field(proto.STRING, number=1,) | 144 | 163 | read_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) | 145 | 164 | asset_types = proto.RepeatedField(proto.STRING, number=3,) | 146 | 165 | content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",) | 147 | 166 | output_config = proto.Field(proto.MESSAGE, number=5, message="OutputConfig",) | | 167 | + relationship_types = proto.RepeatedField(proto.STRING, number=6,) | 148 | 168 |
| 149 | 169 |
| 150 | 170 | class ExportAssetsResponse(proto.Message): | @@ -228,6 +248,23 @@ class ListAssetsRequest(proto.Message): | 228 | 248 | ``ListAssetsRequest``. It is a continuation of a prior | 229 | 249 | ``ListAssets`` call, and the API should return the next page | 230 | 250 | 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. | 231 | 268 | """ | 232 | 269 |
| 233 | 270 | parent = proto.Field(proto.STRING, number=1,) | @@ -236,6 +273,7 @@ class ListAssetsRequest(proto.Message): | 236 | 273 | content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",) | 237 | 274 | page_size = proto.Field(proto.INT32, number=5,) | 238 | 275 | page_token = proto.Field(proto.STRING, number=6,) | | 276 | + relationship_types = proto.RepeatedField(proto.STRING, number=7,) | 239 | 277 |
| 240 | 278 |
| 241 | 279 | class ListAssetsResponse(proto.Message): | @@ -290,6 +328,23 @@ class BatchGetAssetsHistoryRequest(proto.Message): | 290 | 328 | not set, the snapshot of the assets at end_time will be | 291 | 329 | returned. The returned results contain all temporal assets | 292 | 330 | 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. | 293 | 348 | """ | 294 | 349 |
| 295 | 350 | parent = proto.Field(proto.STRING, number=1,) | @@ -298,6 +353,7 @@ class BatchGetAssetsHistoryRequest(proto.Message): | 298 | 353 | read_time_window = proto.Field( | 299 | 354 | proto.MESSAGE, number=4, message=gca_assets.TimeWindow, | 300 | 355 | ) | | 356 | + relationship_types = proto.RepeatedField(proto.STRING, number=5,) | 301 | 357 |
| 302 | 358 |
| 303 | 359 | class BatchGetAssetsHistoryResponse(proto.Message): | @@ -675,6 +731,25 @@ class Feed(proto.Message): | 675 | 731 | See our `user | 676 | 732 | guide <https://cloud.google.com/asset-inventory/docs/monitoring-asset-changes-with-condition>`__ | 677 | 733 | 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. | 678 | 753 | """ | 679 | 754 |
| 680 | 755 | name = proto.Field(proto.STRING, number=1,) | @@ -685,6 +760,7 @@ class Feed(proto.Message): | 685 | 760 | proto.MESSAGE, number=5, message="FeedOutputConfig", | 686 | 761 | ) | 687 | 762 | condition = proto.Field(proto.MESSAGE, number=6, message=expr_pb2.Expr,) | | 763 | + relationship_types = proto.RepeatedField(proto.STRING, number=7,) | 688 | 764 |
| 689 | 765 |
| 690 | 766 | class SearchAllResourcesRequest(proto.Message): | |
Collapse file Copy file name to clipboardExpand all lines: google/cloud/asset_v1/types/assets.py +90Lines changed: 90 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 33 | 33 | "TimeWindow", | 34 | 34 | "Asset", | 35 | 35 | "Resource", | | 36 | + "RelatedAssets", | | 37 | + "RelationshipAttributes", | | 38 | + "RelatedAsset", | 36 | 39 | "ResourceSearchResult", | 37 | 40 | "VersionedResource", | 38 | 41 | "AttachedResource", | @@ -157,6 +160,10 @@ class Asset(proto.Message): | 157 | 160 | `this | 158 | 161 | topic <https://cloud.google.com/compute/docs/instances/os-inventory-management>`__ | 159 | 162 | 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. | 160 | 167 | ancestors (Sequence[str]): | 161 | 168 | The ancestry path of an asset in Google Cloud `resource | 162 | 169 | hierarchy <https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy>`__, | @@ -199,6 +206,7 @@ class Asset(proto.Message): | 199 | 206 | message=service_perimeter_pb2.ServicePerimeter, | 200 | 207 | ) | 201 | 208 | os_inventory = proto.Field(proto.MESSAGE, number=12, message=Inventory,) | | 209 | + related_assets = proto.Field(proto.MESSAGE, number=13, message="RelatedAssets",) | 202 | 210 | ancestors = proto.RepeatedField(proto.STRING, number=10,) | 203 | 211 |
| 204 | 212 |
| @@ -259,6 +267,88 @@ class Resource(proto.Message): | 259 | 267 | location = proto.Field(proto.STRING, number=8,) | 260 | 268 |
| 261 | 269 |
| | 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 | + | 262 | 352 | class ResourceSearchResult(proto.Message): | 263 | 353 | r"""A result of Resource Search, containing information of a | 264 | 354 | cloud resource. | |
Collapse file Copy file name to clipboardExpand all lines: scripts/fixup_asset_v1_keywords.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -42,12 +42,12 @@ class assetCallTransformer(cst.CSTTransformer): | 42 | 42 | 'analyze_iam_policy': ('analysis_query', 'execution_timeout', ), | 43 | 43 | 'analyze_iam_policy_longrunning': ('analysis_query', 'output_config', ), | 44 | 44 | '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', ), | 46 | 46 | 'create_feed': ('parent', 'feed_id', 'feed', ), | 47 | 47 | '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', ), | 49 | 49 | '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', ), | 51 | 51 | 'list_feeds': ('parent', ), | 52 | 52 | 'search_all_iam_policies': ('scope', 'query', 'page_size', 'page_token', 'asset_types', 'order_by', ), | 53 | 53 | 'search_all_resources': ('scope', 'query', 'asset_types', 'page_size', 'page_token', 'order_by', 'read_mask', ), | |
|