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 to support relationship export by gcf-owl-bot[bot] · Pull Request #262 · googleapis/python-asset

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

feat: Release of relationships in v1, Add content type Relationship to support relationship export #262

Merged
busunkim96 merged 2 commits into master from owl-bot-982b6376-a5f3-4365-9e2d-5db1249df0e7
Aug 17, 2021

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat: Release of relationships in v1, Add content type Relationship to support relationship export #262

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
982eb4f
feat: Release of relationships in v1, Add content type Relationship t…
gcf-owl-bot[bot] Aug 16, 2021
9aead75
🦉 Updates from OwlBot
gcf-owl-bot[bot] Aug 16, 2021
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

6 changes: 6 additions & 0 deletions 6 google/cloud/asset/__init__.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
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
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 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 TemporalAsset
Expand Down Expand Up @@ -120,6 +123,9 @@
"IamPolicyAnalysisResult",
"IamPolicyAnalysisState",
"IamPolicySearchResult",
"RelatedAsset",
"RelatedAssets",
"RelationshipAttributes",
"Resource",
"ResourceSearchResult",
"TemporalAsset",
Expand Down
6 changes: 6 additions & 0 deletions 6 google/cloud/asset_v1/__init__.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
from .types.assets import IamPolicyAnalysisResult
from .types.assets import IamPolicyAnalysisState
from .types.assets import IamPolicySearchResult
from .types.assets import RelatedAsset
from .types.assets import RelatedAssets
from .types.assets import RelationshipAttributes
from .types.assets import Resource
from .types.assets import ResourceSearchResult
from .types.assets import TemporalAsset
Expand Down Expand Up @@ -109,6 +112,9 @@
"OutputResult",
"PartitionSpec",
"PubsubDestination",
"RelatedAsset",
"RelatedAssets",
"RelationshipAttributes",
"Resource",
"ResourceSearchResult",
"SearchAllIamPoliciesRequest",
Expand Down
6 changes: 6 additions & 0 deletions 6 google/cloud/asset_v1/types/__init__.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
IamPolicyAnalysisResult,
IamPolicyAnalysisState,
IamPolicySearchResult,
RelatedAsset,
RelatedAssets,
RelationshipAttributes,
Resource,
ResourceSearchResult,
TemporalAsset,
Expand Down Expand Up @@ -112,6 +115,9 @@
"IamPolicyAnalysisResult",
"IamPolicyAnalysisState",
"IamPolicySearchResult",
"RelatedAsset",
"RelatedAssets",
"RelationshipAttributes",
"Resource",
"ResourceSearchResult",
"TemporalAsset",
Expand Down
78 changes: 77 additions & 1 deletion 78 google/cloud/asset_v1/types/asset_service.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class ContentType(proto.Enum):
ORG_POLICY = 4
ACCESS_POLICY = 5
OS_INVENTORY = 6
RELATIONSHIP = 7


class AnalyzeIamPolicyLongrunningMetadata(proto.Message):
Expand All @@ -84,7 +85,8 @@ class AnalyzeIamPolicyLongrunningMetadata(proto.Message):

Attributes:
create_time (google.protobuf.timestamp_pb2.Timestamp):
The time the operation was created.
Output only. The time the operation was
created.
"""

create_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,)
Expand Down Expand Up @@ -138,13 +140,31 @@ class ExportAssetsRequest(proto.Message):
output_config (google.cloud.asset_v1.types.OutputConfig):
Required. Output configuration indicating
where the results will be output to.
relationship_types (Sequence[str]):
A list of relationship types to export, for example:
``INSTANCE_TO_INSTANCEGROUP``. This field should only be
specified if content_type=RELATIONSHIP.

- If specified: it snapshots specified relationships. It
returns an error if any of the [relationship_types]
doesn't belong to the supported relationship types of the
[asset_types] or if any of the [asset_types] doesn't
belong to the source types of the [relationship_types].
- Otherwise: it snapshots the supported relationships for
all [asset_types] or returns an error if any of the
[asset_types] has no relationship support. An unspecified
asset types field means all supported asset_types. See
`Introduction to Cloud Asset
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
for all supported asset types and relationship types.
"""

parent = proto.Field(proto.STRING, number=1,)
read_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,)
asset_types = proto.RepeatedField(proto.STRING, number=3,)
content_type = proto.Field(proto.ENUM, number=4, enum="ContentType",)
output_config = proto.Field(proto.MESSAGE, number=5, message="OutputConfig",)
relationship_types = proto.RepeatedField(proto.STRING, number=6,)


class ExportAssetsResponse(proto.Message):
Expand Down Expand Up @@ -228,6 +248,23 @@ class ListAssetsRequest(proto.Message):
``ListAssetsRequest``. It is a continuation of a prior
``ListAssets`` call, and the API should return the next page
of assets.
relationship_types (Sequence[str]):
A list of relationship types to output, for example:
``INSTANCE_TO_INSTANCEGROUP``. This field should only be
specified if content_type=RELATIONSHIP.

- If specified: it snapshots specified relationships. It
returns an error if any of the [relationship_types]
doesn't belong to the supported relationship types of the
[asset_types] or if any of the [asset_types] doesn't
belong to the source types of the [relationship_types].
- Otherwise: it snapshots the supported relationships for
all [asset_types] or returns an error if any of the
[asset_types] has no relationship support. An unspecified
asset types field means all supported asset_types. See
`Introduction to Cloud Asset
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
for all supported asset types and relationship types.
"""

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


class ListAssetsResponse(proto.Message):
Expand Down Expand Up @@ -290,6 +328,23 @@ class BatchGetAssetsHistoryRequest(proto.Message):
not set, the snapshot of the assets at end_time will be
returned. The returned results contain all temporal assets
whose time window overlap with read_time_window.
relationship_types (Sequence[str]):
Optional. A list of relationship types to output, for
example: ``INSTANCE_TO_INSTANCEGROUP``. This field should
only be specified if content_type=RELATIONSHIP.

- If specified: it outputs specified relationships' history
on the [asset_names]. It returns an error if any of the
[relationship_types] doesn't belong to the supported
relationship types of the [asset_names] or if any of the
[asset_names]'s types doesn't belong to the source types
of the [relationship_types].
- Otherwise: it outputs the supported relationships'
history on the [asset_names] or returns an error if any
of the [asset_names]'s types has no relationship support.
See `Introduction to Cloud Asset
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
for all supported asset types and relationship types.
"""

parent = proto.Field(proto.STRING, number=1,)
Expand All @@ -298,6 +353,7 @@ class BatchGetAssetsHistoryRequest(proto.Message):
read_time_window = proto.Field(
proto.MESSAGE, number=4, message=gca_assets.TimeWindow,
)
relationship_types = proto.RepeatedField(proto.STRING, number=5,)


class BatchGetAssetsHistoryResponse(proto.Message):
Expand Down Expand Up @@ -675,6 +731,25 @@ class Feed(proto.Message):
See our `user
guide <https://cloud.google.com/asset-inventory/docs/monitoring-asset-changes-with-condition>`__
for detailed instructions.
relationship_types (Sequence[str]):
A list of relationship types to output, for example:
``INSTANCE_TO_INSTANCEGROUP``. This field should only be
specified if content_type=RELATIONSHIP.

- If specified: it outputs specified relationship updates
on the [asset_names] or the [asset_types]. It returns an
error if any of the [relationship_types] doesn't belong
to the supported relationship types of the [asset_names]
or [asset_types], or any of the [asset_names] or the
[asset_types] doesn't belong to the source types of the
[relationship_types].
- Otherwise: it outputs the supported relationships of the
types of [asset_names] and [asset_types] or returns an
error if any of the [asset_names] or the [asset_types]
has no replationship support. See `Introduction to Cloud
Asset
Inventory <https://cloud.google.com/asset-inventory/docs/overview>`__
for all supported asset types and relationship types.
"""

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


class SearchAllResourcesRequest(proto.Message):
Expand Down
90 changes: 90 additions & 0 deletions 90 google/cloud/asset_v1/types/assets.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
"TimeWindow",
"Asset",
"Resource",
"RelatedAssets",
"RelationshipAttributes",
"RelatedAsset",
"ResourceSearchResult",
"VersionedResource",
"AttachedResource",
Expand Down Expand Up @@ -157,6 +160,10 @@ class Asset(proto.Message):
`this
topic <https://cloud.google.com/compute/docs/instances/os-inventory-management>`__
for more information.
related_assets (google.cloud.asset_v1.types.RelatedAssets):
The related assets of the asset of one
relationship type. One asset only represents one
type of relationship.
ancestors (Sequence[str]):
The ancestry path of an asset in Google Cloud `resource
hierarchy <https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy>`__,
Expand Down Expand Up @@ -199,6 +206,7 @@ class Asset(proto.Message):
message=service_perimeter_pb2.ServicePerimeter,
)
os_inventory = proto.Field(proto.MESSAGE, number=12, message=Inventory,)
related_assets = proto.Field(proto.MESSAGE, number=13, message="RelatedAssets",)
ancestors = proto.RepeatedField(proto.STRING, number=10,)


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


class RelatedAssets(proto.Message):
r"""The detailed related assets with the ``relationship_type``.
Attributes:
relationship_attributes (google.cloud.asset_v1.types.RelationshipAttributes):
The detailed relationship attributes.
assets (Sequence[google.cloud.asset_v1.types.RelatedAsset]):
The peer resources of the relationship.
"""

relationship_attributes = proto.Field(
proto.MESSAGE, number=1, message="RelationshipAttributes",
)
assets = proto.RepeatedField(proto.MESSAGE, number=2, message="RelatedAsset",)


class RelationshipAttributes(proto.Message):
r"""The relationship attributes which include ``type``,
``source_resource_type``, ``target_resource_type`` and ``action``.

Attributes:
type_ (str):
The unique identifier of the relationship type. Example:
``INSTANCE_TO_INSTANCEGROUP``
source_resource_type (str):
The source asset type. Example:
``compute.googleapis.com/Instance``
target_resource_type (str):
The target asset type. Example:
``compute.googleapis.com/Disk``
action (str):
The detail of the relationship, e.g. ``contains``,
``attaches``
"""

type_ = proto.Field(proto.STRING, number=4,)
source_resource_type = proto.Field(proto.STRING, number=1,)
target_resource_type = proto.Field(proto.STRING, number=2,)
action = proto.Field(proto.STRING, number=3,)


class RelatedAsset(proto.Message):
r"""An asset identify in Google Cloud which contains its name, type and
ancestors. An asset can be any resource in the Google Cloud
`resource
hierarchy <https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy>`__,
a resource outside the Google Cloud resource hierarchy (such as
Google Kubernetes Engine clusters and objects), or a policy (e.g.
Cloud IAM policy). See `Supported asset
types <https://cloud.google.com/asset-inventory/docs/supported-asset-types>`__
for more information.

Attributes:
asset (str):
The full name of the asset. Example:
``//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1``

See `Resource
names <https://cloud.google.com/apis/design/resource_names#full_resource_name>`__
for more information.
asset_type (str):
The type of the asset. Example:
``compute.googleapis.com/Disk``

See `Supported asset
types <https://cloud.google.com/asset-inventory/docs/supported-asset-types>`__
for more information.
ancestors (Sequence[str]):
The ancestors of an asset in Google Cloud `resource
hierarchy <https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy>`__,
represented as a list of relative resource names. An
ancestry path starts with the closest ancestor in the
hierarchy and ends at root.

Example:
``["projects/123456789", "folders/5432", "organizations/1234"]``
"""

asset = proto.Field(proto.STRING, number=1,)
asset_type = proto.Field(proto.STRING, number=2,)
ancestors = proto.RepeatedField(proto.STRING, number=3,)


class ResourceSearchResult(proto.Message):
r"""A result of Resource Search, containing information of a
cloud resource.
Expand Down
6 changes: 3 additions & 3 deletions 6 scripts/fixup_asset_v1_keywords.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class assetCallTransformer(cst.CSTTransformer):
'analyze_iam_policy': ('analysis_query', 'execution_timeout', ),
'analyze_iam_policy_longrunning': ('analysis_query', 'output_config', ),
'analyze_move': ('resource', 'destination_parent', 'view', ),
'batch_get_assets_history': ('parent', 'asset_names', 'content_type', 'read_time_window', ),
'batch_get_assets_history': ('parent', 'asset_names', 'content_type', 'read_time_window', 'relationship_types', ),
'create_feed': ('parent', 'feed_id', 'feed', ),
'delete_feed': ('name', ),
'export_assets': ('parent', 'output_config', 'read_time', 'asset_types', 'content_type', ),
'export_assets': ('parent', 'output_config', 'read_time', 'asset_types', 'content_type', 'relationship_types', ),
'get_feed': ('name', ),
'list_assets': ('parent', 'read_time', 'asset_types', 'content_type', 'page_size', 'page_token', ),
'list_assets': ('parent', 'read_time', 'asset_types', 'content_type', 'page_size', 'page_token', 'relationship_types', ),
'list_feeds': ('parent', ),
'search_all_iam_policies': ('scope', 'query', 'page_size', 'page_token', 'asset_types', 'order_by', ),
'search_all_resources': ('scope', 'query', 'asset_types', 'page_size', 'page_token', 'order_by', 'read_mask', ),
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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.