From f227ea39b79970592e8db66e8d39fb7fb8ab17e7 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 3 Sep 2021 09:12:09 +0000 Subject: [PATCH] feat(v1): add relationships (#281) - [ ] Regenerate this pull request now. PiperOrigin-RevId: 394579113 Committer yuwangyw@ Source-Link: https://github.com/googleapis/googleapis/commit/9c7eb1f9a78060a15cc309ab51ee0600c2e6f4f7 Source-Link: https://github.com/googleapis/googleapis-gen/commit/59343840421bcd9e507dec9b7e0aaa76ea71d2e6 feat(v1): Add content type Relationship to support relationship search --- .../google/cloud/asset/__init__.py | 4 ++ .../google/cloud/asset_v1/__init__.py | 4 ++ .../google/cloud/asset_v1/types/__init__.py | 4 ++ .../google/cloud/asset_v1/types/assets.py | 40 +++++++++++++++++++ 4 files changed, 52 insertions(+) diff --git a/packages/google-cloud-asset/google/cloud/asset/__init__.py b/packages/google-cloud-asset/google/cloud/asset/__init__.py index ae1a5cd644e5..d8b042e95274 100644 --- a/packages/google-cloud-asset/google/cloud/asset/__init__.py +++ b/packages/google-cloud-asset/google/cloud/asset/__init__.py @@ -69,6 +69,8 @@ from google.cloud.asset_v1.types.assets import IamPolicySearchResult from google.cloud.asset_v1.types.assets import RelatedAsset from google.cloud.asset_v1.types.assets import RelatedAssets +from google.cloud.asset_v1.types.assets import RelatedResource +from google.cloud.asset_v1.types.assets import RelatedResources 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 @@ -125,6 +127,8 @@ "IamPolicySearchResult", "RelatedAsset", "RelatedAssets", + "RelatedResource", + "RelatedResources", "RelationshipAttributes", "Resource", "ResourceSearchResult", diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/__init__.py b/packages/google-cloud-asset/google/cloud/asset_v1/__init__.py index 5628bd256ac4..1dfd90c9c3b1 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/__init__.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/__init__.py @@ -63,6 +63,8 @@ from .types.assets import IamPolicySearchResult from .types.assets import RelatedAsset from .types.assets import RelatedAssets +from .types.assets import RelatedResource +from .types.assets import RelatedResources from .types.assets import RelationshipAttributes from .types.assets import Resource from .types.assets import ResourceSearchResult @@ -114,6 +116,8 @@ "PubsubDestination", "RelatedAsset", "RelatedAssets", + "RelatedResource", + "RelatedResources", "RelationshipAttributes", "Resource", "ResourceSearchResult", diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/types/__init__.py b/packages/google-cloud-asset/google/cloud/asset_v1/types/__init__.py index 6fd16f4b20b4..43e76c1ebe42 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/types/__init__.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/types/__init__.py @@ -62,6 +62,8 @@ IamPolicySearchResult, RelatedAsset, RelatedAssets, + RelatedResource, + RelatedResources, RelationshipAttributes, Resource, ResourceSearchResult, @@ -117,6 +119,8 @@ "IamPolicySearchResult", "RelatedAsset", "RelatedAssets", + "RelatedResource", + "RelatedResources", "RelationshipAttributes", "Resource", "ResourceSearchResult", diff --git a/packages/google-cloud-asset/google/cloud/asset_v1/types/assets.py b/packages/google-cloud-asset/google/cloud/asset_v1/types/assets.py index a09daeeb9c2d..a159c426e048 100644 --- a/packages/google-cloud-asset/google/cloud/asset_v1/types/assets.py +++ b/packages/google-cloud-asset/google/cloud/asset_v1/types/assets.py @@ -39,6 +39,8 @@ "ResourceSearchResult", "VersionedResource", "AttachedResource", + "RelatedResources", + "RelatedResource", "IamPolicySearchResult", "IamPolicyAnalysisState", "ConditionEvaluation", @@ -575,6 +577,13 @@ class ResourceSearchResult(proto.Message): attributes of the attached resources are exposed in ``additional_attributes`` field, so as to allow users to search on them. + relationships (Sequence[google.cloud.asset_v1.types.ResourceSearchResult.RelationshipsEntry]): + A map of related resources of this resource, keyed by the + relationship type. A relationship type is in the format of + {SourceType}*{ACTION}*\ {DestType}. Example: + ``DISK_TO_INSTANCE``, ``DISK_TO_NETWORK``, + ``INSTANCE_TO_INSTANCEGROUP``. See `supported relationship + types `__. parent_asset_type (str): The type of this resource's immediate parent, if there is one. @@ -615,6 +624,9 @@ class ResourceSearchResult(proto.Message): attached_resources = proto.RepeatedField( proto.MESSAGE, number=20, message="AttachedResource", ) + relationships = proto.MapField( + proto.STRING, proto.MESSAGE, number=21, message="RelatedResources", + ) parent_asset_type = proto.Field(proto.STRING, number=103,) @@ -676,6 +688,34 @@ class AttachedResource(proto.Message): ) +class RelatedResources(proto.Message): + r"""The related resources of the primary resource. + Attributes: + related_resources (Sequence[google.cloud.asset_v1.types.RelatedResource]): + The detailed related resources of the primary + resource. + """ + + related_resources = proto.RepeatedField( + proto.MESSAGE, number=1, message="RelatedResource", + ) + + +class RelatedResource(proto.Message): + r"""The detailed related resource. + Attributes: + asset_type (str): + The type of the asset. Example: + ``compute.googleapis.com/Instance`` + full_resource_name (str): + The full resource name of the related resource. Example: + ``//compute.googleapis.com/projects/my_proj_123/zones/instance/instance123`` + """ + + asset_type = proto.Field(proto.STRING, number=1,) + full_resource_name = proto.Field(proto.STRING, number=2,) + + class IamPolicySearchResult(proto.Message): r"""A result of IAM Policy search, containing information of an IAM policy.