Skip to content

Commit

Permalink
feat(asset): add real time feed support to v1 (via synth) (#9930)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and busunkim96 committed Dec 12, 2019
1 parent 7dff593 commit fdd7246
Show file tree
Hide file tree
Showing 12 changed files with 1,891 additions and 71 deletions.
410 changes: 410 additions & 0 deletions asset/google/cloud/asset_v1/gapic/asset_service_client.py

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions asset/google/cloud/asset_v1/gapic/asset_service_client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"CreateFeed": {
"timeout_millis": 30000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetFeed": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListFeeds": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"UpdateFeed": {
"timeout_millis": 30000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"DeleteFeed": {
"timeout_millis": 30000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,69 @@ def batch_get_assets_history(self):
deserialized response object.
"""
return self._stubs["asset_service_stub"].BatchGetAssetsHistory

@property
def create_feed(self):
"""Return the gRPC stub for :meth:`AssetServiceClient.create_feed`.
Creates a feed in a parent project/folder/organization to listen to its
asset updates.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["asset_service_stub"].CreateFeed

@property
def get_feed(self):
"""Return the gRPC stub for :meth:`AssetServiceClient.get_feed`.
Gets details about an asset feed.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["asset_service_stub"].GetFeed

@property
def list_feeds(self):
"""Return the gRPC stub for :meth:`AssetServiceClient.list_feeds`.
Lists all asset feeds in a parent project/folder/organization.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["asset_service_stub"].ListFeeds

@property
def update_feed(self):
"""Return the gRPC stub for :meth:`AssetServiceClient.update_feed`.
Updates an asset feed configuration.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["asset_service_stub"].UpdateFeed

@property
def delete_feed(self):
"""Return the gRPC stub for :meth:`AssetServiceClient.delete_feed`.
Deletes an asset feed.
Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
deserialized response object.
"""
return self._stubs["asset_service_stub"].DeleteFeed
186 changes: 186 additions & 0 deletions asset/google/cloud/asset_v1/proto/asset_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,49 @@ service AssetService {
get: "/v1/{parent=*/*}:batchGetAssetsHistory"
};
}

// Creates a feed in a parent project/folder/organization to listen to its
// asset updates.
rpc CreateFeed(CreateFeedRequest) returns (Feed) {
option (google.api.http) = {
post: "/v1/{parent=*/*}/feeds"
body: "*"
};
option (google.api.method_signature) = "parent";
}

// Gets details about an asset feed.
rpc GetFeed(GetFeedRequest) returns (Feed) {
option (google.api.http) = {
get: "/v1/{name=*/*/feeds/*}"
};
option (google.api.method_signature) = "name";
}

// Lists all asset feeds in a parent project/folder/organization.
rpc ListFeeds(ListFeedsRequest) returns (ListFeedsResponse) {
option (google.api.http) = {
get: "/v1/{parent=*/*}/feeds"
};
option (google.api.method_signature) = "parent";
}

// Updates an asset feed configuration.
rpc UpdateFeed(UpdateFeedRequest) returns (Feed) {
option (google.api.http) = {
patch: "/v1/{feed.name=*/*/feeds/*}"
body: "*"
};
option (google.api.method_signature) = "feed";
}

// Deletes an asset feed.
rpc DeleteFeed(DeleteFeedRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/v1/{name=*/*/feeds/*}"
};
option (google.api.method_signature) = "name";
}
}

// Export asset request.
Expand Down Expand Up @@ -158,6 +201,82 @@ message BatchGetAssetsHistoryResponse {
repeated TemporalAsset assets = 1;
}

// Create asset feed request.
message CreateFeedRequest {
// Required. The name of the project/folder/organization where this feed
// should be created in. It can only be an organization number (such as
// "organizations/123"), a folder number (such as "folders/123"), a project ID
// (such as "projects/my-project-id")", or a project number (such as
// "projects/12345").
string parent = 1 [(google.api.field_behavior) = REQUIRED];

// Required. This is the client-assigned asset feed identifier and it needs to
// be unique under a specific parent project/folder/organization.
string feed_id = 2 [(google.api.field_behavior) = REQUIRED];

// Required. The feed details. The field `name` must be empty and it will be generated
// in the format of:
// projects/project_number/feeds/feed_id
// folders/folder_number/feeds/feed_id
// organizations/organization_number/feeds/feed_id
Feed feed = 3 [(google.api.field_behavior) = REQUIRED];
}

// Get asset feed request.
message GetFeedRequest {
// Required. The name of the Feed and it must be in the format of:
// projects/project_number/feeds/feed_id
// folders/folder_number/feeds/feed_id
// organizations/organization_number/feeds/feed_id
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "cloudasset.googleapis.com/Feed"
}
];
}

// List asset feeds request.
message ListFeedsRequest {
// Required. The parent project/folder/organization whose feeds are to be
// listed. It can only be using project/folder/organization number (such as
// "folders/12345")", or a project ID (such as "projects/my-project-id").
string parent = 1 [(google.api.field_behavior) = REQUIRED];
}

message ListFeedsResponse {
// A list of feeds.
repeated Feed feeds = 1;
}

// Update asset feed request.
message UpdateFeedRequest {
// Required. The new values of feed details. It must match an existing feed and the
// field `name` must be in the format of:
// projects/project_number/feeds/feed_id or
// folders/folder_number/feeds/feed_id or
// organizations/organization_number/feeds/feed_id.
Feed feed = 1 [(google.api.field_behavior) = REQUIRED];

// Required. Only updates the `feed` fields indicated by this mask.
// The field mask must not be empty, and it must not contain fields that
// are immutable or only set by the server.
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
}

message DeleteFeedRequest {
// Required. The name of the feed and it must be in the format of:
// projects/project_number/feeds/feed_id
// folders/folder_number/feeds/feed_id
// organizations/organization_number/feeds/feed_id
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {
type: "cloudasset.googleapis.com/Feed"
}
];
}

// Output configuration for export assets destination.
message OutputConfig {
// Asset export destination.
Expand Down Expand Up @@ -217,6 +336,13 @@ message BigQueryDestination {
bool force = 3;
}

// A Cloud Pubsub destination.
message PubsubDestination {
// The name of the Cloud Pub/Sub topic to publish to.
// For example: `projects/PROJECT_ID/topics/TOPIC_ID`.
string topic = 1;
}

// Asset content type.
enum ContentType {
// Unspecified content type.
Expand All @@ -234,3 +360,63 @@ enum ContentType {
// The Cloud Access context mananger Policy set on an asset.
ACCESS_POLICY = 5;
}

// Output configuration for asset feed destination.
message FeedOutputConfig {
// Asset feed destination.
oneof destination {
// Destination on Cloud Pubsub.
PubsubDestination pubsub_destination = 1;
}
}

// An asset feed used to export asset updates to a destinations.
// An asset feed filter controls what updates are exported.
// The asset feed must be created within a project, organization, or
// folder. Supported destinations are:
// Cloud Pub/Sub topics.
message Feed {
option (google.api.resource) = {
type: "cloudasset.googleapis.com/Feed"
pattern: "projects/{project}/feeds/{feed}"
pattern: "folders/{folder}/feeds/{feed}"
pattern: "organizations/{organization}/feeds/{feed}"
history: ORIGINALLY_SINGLE_PATTERN
};

// Required. The format will be
// projects/{project_number}/feeds/{client-assigned_feed_identifier} or
// folders/{folder_number}/feeds/{client-assigned_feed_identifier} or
// organizations/{organization_number}/feeds/{client-assigned_feed_identifier}
//
// The client-assigned feed identifier must be unique within the parent
// project/folder/organization.
string name = 1 [(google.api.field_behavior) = REQUIRED];

// A list of the full names of the assets to receive updates. You must specify
// either or both of asset_names and asset_types. Only asset updates matching
// specified asset_names and asset_types are exported to the feed. For
// 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 info.
repeated string asset_names = 2;

// A list of types of the assets to receive updates. You must specify either
// or both of asset_names and asset_types. Only asset updates matching
// specified asset_names and asset_types are exported to the feed.
// For example:
// "compute.googleapis.com/Disk" See [Introduction to Cloud Asset
// Inventory](https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview)
// for all supported asset types.
repeated string asset_types = 3;

// Asset content type. If not specified, no content but the asset name and
// type will be returned.
ContentType content_type = 4;

// Required. Feed output configuration defining where the asset updates are
// published to.
FeedOutputConfig feed_output_config = 5 [(google.api.field_behavior) = REQUIRED];
}
Loading

0 comments on commit fdd7246

Please sign in to comment.