Skip to content

Commit f9dd5a6

Browse files
yoshi-automationbusunkim96
authored andcommitted
feat(asset): add real time feed support to v1 (via synth) (#9930)
1 parent 0015b0f commit f9dd5a6

File tree

12 files changed

+1891
-71
lines changed

12 files changed

+1891
-71
lines changed

packages/google-cloud-asset/google/cloud/asset_v1/gapic/asset_service_client.py

Lines changed: 410 additions & 0 deletions
Large diffs are not rendered by default.

packages/google-cloud-asset/google/cloud/asset_v1/gapic/asset_service_client_config.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@
2727
"retry_codes_name": "idempotent",
2828
"retry_params_name": "default",
2929
},
30+
"CreateFeed": {
31+
"timeout_millis": 30000,
32+
"retry_codes_name": "non_idempotent",
33+
"retry_params_name": "default",
34+
},
35+
"GetFeed": {
36+
"timeout_millis": 10000,
37+
"retry_codes_name": "idempotent",
38+
"retry_params_name": "default",
39+
},
40+
"ListFeeds": {
41+
"timeout_millis": 10000,
42+
"retry_codes_name": "idempotent",
43+
"retry_params_name": "default",
44+
},
45+
"UpdateFeed": {
46+
"timeout_millis": 30000,
47+
"retry_codes_name": "non_idempotent",
48+
"retry_params_name": "default",
49+
},
50+
"DeleteFeed": {
51+
"timeout_millis": 30000,
52+
"retry_codes_name": "idempotent",
53+
"retry_params_name": "default",
54+
},
3055
},
3156
}
3257
}

packages/google-cloud-asset/google/cloud/asset_v1/gapic/transports/asset_service_grpc_transport.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,69 @@ def batch_get_assets_history(self):
148148
deserialized response object.
149149
"""
150150
return self._stubs["asset_service_stub"].BatchGetAssetsHistory
151+
152+
@property
153+
def create_feed(self):
154+
"""Return the gRPC stub for :meth:`AssetServiceClient.create_feed`.
155+
156+
Creates a feed in a parent project/folder/organization to listen to its
157+
asset updates.
158+
159+
Returns:
160+
Callable: A callable which accepts the appropriate
161+
deserialized request object and returns a
162+
deserialized response object.
163+
"""
164+
return self._stubs["asset_service_stub"].CreateFeed
165+
166+
@property
167+
def get_feed(self):
168+
"""Return the gRPC stub for :meth:`AssetServiceClient.get_feed`.
169+
170+
Gets details about an asset feed.
171+
172+
Returns:
173+
Callable: A callable which accepts the appropriate
174+
deserialized request object and returns a
175+
deserialized response object.
176+
"""
177+
return self._stubs["asset_service_stub"].GetFeed
178+
179+
@property
180+
def list_feeds(self):
181+
"""Return the gRPC stub for :meth:`AssetServiceClient.list_feeds`.
182+
183+
Lists all asset feeds in a parent project/folder/organization.
184+
185+
Returns:
186+
Callable: A callable which accepts the appropriate
187+
deserialized request object and returns a
188+
deserialized response object.
189+
"""
190+
return self._stubs["asset_service_stub"].ListFeeds
191+
192+
@property
193+
def update_feed(self):
194+
"""Return the gRPC stub for :meth:`AssetServiceClient.update_feed`.
195+
196+
Updates an asset feed configuration.
197+
198+
Returns:
199+
Callable: A callable which accepts the appropriate
200+
deserialized request object and returns a
201+
deserialized response object.
202+
"""
203+
return self._stubs["asset_service_stub"].UpdateFeed
204+
205+
@property
206+
def delete_feed(self):
207+
"""Return the gRPC stub for :meth:`AssetServiceClient.delete_feed`.
208+
209+
Deletes an asset feed.
210+
211+
Returns:
212+
Callable: A callable which accepts the appropriate
213+
deserialized request object and returns a
214+
deserialized response object.
215+
"""
216+
return self._stubs["asset_service_stub"].DeleteFeed

packages/google-cloud-asset/google/cloud/asset_v1/proto/asset_service.proto

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,49 @@ service AssetService {
6666
get: "/v1/{parent=*/*}:batchGetAssetsHistory"
6767
};
6868
}
69+
70+
// Creates a feed in a parent project/folder/organization to listen to its
71+
// asset updates.
72+
rpc CreateFeed(CreateFeedRequest) returns (Feed) {
73+
option (google.api.http) = {
74+
post: "/v1/{parent=*/*}/feeds"
75+
body: "*"
76+
};
77+
option (google.api.method_signature) = "parent";
78+
}
79+
80+
// Gets details about an asset feed.
81+
rpc GetFeed(GetFeedRequest) returns (Feed) {
82+
option (google.api.http) = {
83+
get: "/v1/{name=*/*/feeds/*}"
84+
};
85+
option (google.api.method_signature) = "name";
86+
}
87+
88+
// Lists all asset feeds in a parent project/folder/organization.
89+
rpc ListFeeds(ListFeedsRequest) returns (ListFeedsResponse) {
90+
option (google.api.http) = {
91+
get: "/v1/{parent=*/*}/feeds"
92+
};
93+
option (google.api.method_signature) = "parent";
94+
}
95+
96+
// Updates an asset feed configuration.
97+
rpc UpdateFeed(UpdateFeedRequest) returns (Feed) {
98+
option (google.api.http) = {
99+
patch: "/v1/{feed.name=*/*/feeds/*}"
100+
body: "*"
101+
};
102+
option (google.api.method_signature) = "feed";
103+
}
104+
105+
// Deletes an asset feed.
106+
rpc DeleteFeed(DeleteFeedRequest) returns (google.protobuf.Empty) {
107+
option (google.api.http) = {
108+
delete: "/v1/{name=*/*/feeds/*}"
109+
};
110+
option (google.api.method_signature) = "name";
111+
}
69112
}
70113

71114
// Export asset request.
@@ -158,6 +201,82 @@ message BatchGetAssetsHistoryResponse {
158201
repeated TemporalAsset assets = 1;
159202
}
160203

204+
// Create asset feed request.
205+
message CreateFeedRequest {
206+
// Required. The name of the project/folder/organization where this feed
207+
// should be created in. It can only be an organization number (such as
208+
// "organizations/123"), a folder number (such as "folders/123"), a project ID
209+
// (such as "projects/my-project-id")", or a project number (such as
210+
// "projects/12345").
211+
string parent = 1 [(google.api.field_behavior) = REQUIRED];
212+
213+
// Required. This is the client-assigned asset feed identifier and it needs to
214+
// be unique under a specific parent project/folder/organization.
215+
string feed_id = 2 [(google.api.field_behavior) = REQUIRED];
216+
217+
// Required. The feed details. The field `name` must be empty and it will be generated
218+
// in the format of:
219+
// projects/project_number/feeds/feed_id
220+
// folders/folder_number/feeds/feed_id
221+
// organizations/organization_number/feeds/feed_id
222+
Feed feed = 3 [(google.api.field_behavior) = REQUIRED];
223+
}
224+
225+
// Get asset feed request.
226+
message GetFeedRequest {
227+
// Required. The name of the Feed and it must be in the format of:
228+
// projects/project_number/feeds/feed_id
229+
// folders/folder_number/feeds/feed_id
230+
// organizations/organization_number/feeds/feed_id
231+
string name = 1 [
232+
(google.api.field_behavior) = REQUIRED,
233+
(google.api.resource_reference) = {
234+
type: "cloudasset.googleapis.com/Feed"
235+
}
236+
];
237+
}
238+
239+
// List asset feeds request.
240+
message ListFeedsRequest {
241+
// Required. The parent project/folder/organization whose feeds are to be
242+
// listed. It can only be using project/folder/organization number (such as
243+
// "folders/12345")", or a project ID (such as "projects/my-project-id").
244+
string parent = 1 [(google.api.field_behavior) = REQUIRED];
245+
}
246+
247+
message ListFeedsResponse {
248+
// A list of feeds.
249+
repeated Feed feeds = 1;
250+
}
251+
252+
// Update asset feed request.
253+
message UpdateFeedRequest {
254+
// Required. The new values of feed details. It must match an existing feed and the
255+
// field `name` must be in the format of:
256+
// projects/project_number/feeds/feed_id or
257+
// folders/folder_number/feeds/feed_id or
258+
// organizations/organization_number/feeds/feed_id.
259+
Feed feed = 1 [(google.api.field_behavior) = REQUIRED];
260+
261+
// Required. Only updates the `feed` fields indicated by this mask.
262+
// The field mask must not be empty, and it must not contain fields that
263+
// are immutable or only set by the server.
264+
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
265+
}
266+
267+
message DeleteFeedRequest {
268+
// Required. The name of the feed and it must be in the format of:
269+
// projects/project_number/feeds/feed_id
270+
// folders/folder_number/feeds/feed_id
271+
// organizations/organization_number/feeds/feed_id
272+
string name = 1 [
273+
(google.api.field_behavior) = REQUIRED,
274+
(google.api.resource_reference) = {
275+
type: "cloudasset.googleapis.com/Feed"
276+
}
277+
];
278+
}
279+
161280
// Output configuration for export assets destination.
162281
message OutputConfig {
163282
// Asset export destination.
@@ -217,6 +336,13 @@ message BigQueryDestination {
217336
bool force = 3;
218337
}
219338

339+
// A Cloud Pubsub destination.
340+
message PubsubDestination {
341+
// The name of the Cloud Pub/Sub topic to publish to.
342+
// For example: `projects/PROJECT_ID/topics/TOPIC_ID`.
343+
string topic = 1;
344+
}
345+
220346
// Asset content type.
221347
enum ContentType {
222348
// Unspecified content type.
@@ -234,3 +360,63 @@ enum ContentType {
234360
// The Cloud Access context mananger Policy set on an asset.
235361
ACCESS_POLICY = 5;
236362
}
363+
364+
// Output configuration for asset feed destination.
365+
message FeedOutputConfig {
366+
// Asset feed destination.
367+
oneof destination {
368+
// Destination on Cloud Pubsub.
369+
PubsubDestination pubsub_destination = 1;
370+
}
371+
}
372+
373+
// An asset feed used to export asset updates to a destinations.
374+
// An asset feed filter controls what updates are exported.
375+
// The asset feed must be created within a project, organization, or
376+
// folder. Supported destinations are:
377+
// Cloud Pub/Sub topics.
378+
message Feed {
379+
option (google.api.resource) = {
380+
type: "cloudasset.googleapis.com/Feed"
381+
pattern: "projects/{project}/feeds/{feed}"
382+
pattern: "folders/{folder}/feeds/{feed}"
383+
pattern: "organizations/{organization}/feeds/{feed}"
384+
history: ORIGINALLY_SINGLE_PATTERN
385+
};
386+
387+
// Required. The format will be
388+
// projects/{project_number}/feeds/{client-assigned_feed_identifier} or
389+
// folders/{folder_number}/feeds/{client-assigned_feed_identifier} or
390+
// organizations/{organization_number}/feeds/{client-assigned_feed_identifier}
391+
//
392+
// The client-assigned feed identifier must be unique within the parent
393+
// project/folder/organization.
394+
string name = 1 [(google.api.field_behavior) = REQUIRED];
395+
396+
// A list of the full names of the assets to receive updates. You must specify
397+
// either or both of asset_names and asset_types. Only asset updates matching
398+
// specified asset_names and asset_types are exported to the feed. For
399+
// example:
400+
// `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`.
401+
// See [Resource
402+
// Names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
403+
// for more info.
404+
repeated string asset_names = 2;
405+
406+
// A list of types of the assets to receive updates. You must specify either
407+
// or both of asset_names and asset_types. Only asset updates matching
408+
// specified asset_names and asset_types are exported to the feed.
409+
// For example:
410+
// "compute.googleapis.com/Disk" See [Introduction to Cloud Asset
411+
// Inventory](https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview)
412+
// for all supported asset types.
413+
repeated string asset_types = 3;
414+
415+
// Asset content type. If not specified, no content but the asset name and
416+
// type will be returned.
417+
ContentType content_type = 4;
418+
419+
// Required. Feed output configuration defining where the asset updates are
420+
// published to.
421+
FeedOutputConfig feed_output_config = 5 [(google.api.field_behavior) = REQUIRED];
422+
}

0 commit comments

Comments
 (0)