-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 97b833451f8333f884ed4126c003e1be6dde045a Automatic import from cloud_mmv2_dcl_20220826_1531_RC00 by DCL Team <[email protected]> GitOrigin-RevId: 97b833451f8333f884ed4126c003e1be6dde045a
- Loading branch information
1 parent
b91ad81
commit d0bfa6b
Showing
47 changed files
with
7,335 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2022 Google LLC. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
syntax = "proto3"; | ||
// All generated protos should be opaque, with "xxx_hidden_" prepended to their field names. | ||
|
||
|
||
package dcl; | ||
|
||
import "proto/connector/sdk.proto"; | ||
import "proto/empty.proto"; | ||
|
||
|
||
enum EventarcAlphaChannelStateEnum { | ||
EventarcAlphaChannelStateEnumNO_VALUE_DO_NOT_USE = 0; | ||
EventarcAlphaChannelStateEnumSTATE_UNSPECIFIED = 1; | ||
EventarcAlphaChannelStateEnumPENDING = 2; | ||
EventarcAlphaChannelStateEnumACTIVE = 3; | ||
EventarcAlphaChannelStateEnumINACTIVE = 4; | ||
} | ||
|
||
message EventarcAlphaChannel { | ||
string name = 1; | ||
string uid = 2; | ||
string create_time = 3; | ||
string update_time = 4; | ||
string provider = 5; | ||
string pubsub_topic = 6; | ||
EventarcAlphaChannelStateEnum state = 7; | ||
string activation_token = 8; | ||
string crypto_key_name = 9; | ||
string project = 10; | ||
string location = 11; | ||
} | ||
|
||
message ApplyEventarcAlphaChannelRequest { | ||
EventarcAlphaChannel resource = 1; | ||
repeated LifecycleDirective lifecycle_directives = 2; | ||
string service_account_file = 3; | ||
} | ||
|
||
message DeleteEventarcAlphaChannelRequest { | ||
string service_account_file = 1; | ||
EventarcAlphaChannel resource = 2; | ||
} | ||
|
||
message ListEventarcAlphaChannelRequest { | ||
string service_account_file = 1; | ||
string Project = 2; | ||
string Location = 3; | ||
} | ||
|
||
message ListEventarcAlphaChannelResponse { | ||
repeated EventarcAlphaChannel items = 1; | ||
} | ||
|
||
service EventarcAlphaChannelService { | ||
rpc ApplyEventarcAlphaChannel(ApplyEventarcAlphaChannelRequest) returns (EventarcAlphaChannel); | ||
rpc DeleteEventarcAlphaChannel(DeleteEventarcAlphaChannelRequest) returns (google.protobuf.Empty); | ||
rpc ListEventarcAlphaChannel(ListEventarcAlphaChannelRequest) returns (ListEventarcAlphaChannelResponse); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2022 Google LLC. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
syntax = "proto3"; | ||
// All generated protos should be opaque, with "xxx_hidden_" prepended to their field names. | ||
|
||
|
||
package dcl; | ||
|
||
import "proto/connector/sdk.proto"; | ||
import "proto/empty.proto"; | ||
|
||
|
||
enum EventarcBetaChannelStateEnum { | ||
EventarcBetaChannelStateEnumNO_VALUE_DO_NOT_USE = 0; | ||
EventarcBetaChannelStateEnumSTATE_UNSPECIFIED = 1; | ||
EventarcBetaChannelStateEnumPENDING = 2; | ||
EventarcBetaChannelStateEnumACTIVE = 3; | ||
EventarcBetaChannelStateEnumINACTIVE = 4; | ||
} | ||
|
||
message EventarcBetaChannel { | ||
string name = 1; | ||
string uid = 2; | ||
string create_time = 3; | ||
string update_time = 4; | ||
string provider = 5; | ||
string pubsub_topic = 6; | ||
EventarcBetaChannelStateEnum state = 7; | ||
string activation_token = 8; | ||
string crypto_key_name = 9; | ||
string project = 10; | ||
string location = 11; | ||
} | ||
|
||
message ApplyEventarcBetaChannelRequest { | ||
EventarcBetaChannel resource = 1; | ||
repeated LifecycleDirective lifecycle_directives = 2; | ||
string service_account_file = 3; | ||
} | ||
|
||
message DeleteEventarcBetaChannelRequest { | ||
string service_account_file = 1; | ||
EventarcBetaChannel resource = 2; | ||
} | ||
|
||
message ListEventarcBetaChannelRequest { | ||
string service_account_file = 1; | ||
string Project = 2; | ||
string Location = 3; | ||
} | ||
|
||
message ListEventarcBetaChannelResponse { | ||
repeated EventarcBetaChannel items = 1; | ||
} | ||
|
||
service EventarcBetaChannelService { | ||
rpc ApplyEventarcBetaChannel(ApplyEventarcBetaChannelRequest) returns (EventarcBetaChannel); | ||
rpc DeleteEventarcBetaChannel(DeleteEventarcBetaChannelRequest) returns (google.protobuf.Empty); | ||
rpc ListEventarcBetaChannel(ListEventarcBetaChannelRequest) returns (ListEventarcBetaChannelResponse); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2022 Google LLC. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
syntax = "proto3"; | ||
// All generated protos should be opaque, with "xxx_hidden_" prepended to their field names. | ||
|
||
|
||
package dcl; | ||
|
||
import "proto/connector/sdk.proto"; | ||
import "proto/empty.proto"; | ||
|
||
|
||
enum EventarcChannelStateEnum { | ||
EventarcChannelStateEnumNO_VALUE_DO_NOT_USE = 0; | ||
EventarcChannelStateEnumSTATE_UNSPECIFIED = 1; | ||
EventarcChannelStateEnumPENDING = 2; | ||
EventarcChannelStateEnumACTIVE = 3; | ||
EventarcChannelStateEnumINACTIVE = 4; | ||
} | ||
|
||
message EventarcChannel { | ||
string name = 1; | ||
string uid = 2; | ||
string create_time = 3; | ||
string update_time = 4; | ||
string provider = 5; | ||
string pubsub_topic = 6; | ||
EventarcChannelStateEnum state = 7; | ||
string activation_token = 8; | ||
string crypto_key_name = 9; | ||
string project = 10; | ||
string location = 11; | ||
} | ||
|
||
message ApplyEventarcChannelRequest { | ||
EventarcChannel resource = 1; | ||
repeated LifecycleDirective lifecycle_directives = 2; | ||
string service_account_file = 3; | ||
} | ||
|
||
message DeleteEventarcChannelRequest { | ||
string service_account_file = 1; | ||
EventarcChannel resource = 2; | ||
} | ||
|
||
message ListEventarcChannelRequest { | ||
string service_account_file = 1; | ||
string Project = 2; | ||
string Location = 3; | ||
} | ||
|
||
message ListEventarcChannelResponse { | ||
repeated EventarcChannel items = 1; | ||
} | ||
|
||
service EventarcChannelService { | ||
rpc ApplyEventarcChannel(ApplyEventarcChannelRequest) returns (EventarcChannel); | ||
rpc DeleteEventarcChannel(DeleteEventarcChannelRequest) returns (google.protobuf.Empty); | ||
rpc ListEventarcChannel(ListEventarcChannelRequest) returns (ListEventarcChannelResponse); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
# Copyright 2022 Google LLC. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from connector import channel | ||
from google3.cloud.graphite.mmv2.services.google.eventarc import channel_pb2 | ||
from google3.cloud.graphite.mmv2.services.google.eventarc import channel_pb2_grpc | ||
|
||
from typing import List | ||
|
||
|
||
class Channel(object): | ||
def __init__( | ||
self, | ||
name: str = None, | ||
uid: str = None, | ||
create_time: str = None, | ||
update_time: str = None, | ||
provider: str = None, | ||
pubsub_topic: str = None, | ||
state: str = None, | ||
activation_token: str = None, | ||
crypto_key_name: str = None, | ||
project: str = None, | ||
location: str = None, | ||
service_account_file: str = "", | ||
): | ||
|
||
channel.initialize() | ||
self.name = name | ||
self.provider = provider | ||
self.crypto_key_name = crypto_key_name | ||
self.project = project | ||
self.location = location | ||
self.service_account_file = service_account_file | ||
|
||
def apply(self): | ||
stub = channel_pb2_grpc.EventarcAlphaChannelServiceStub(channel.Channel()) | ||
request = channel_pb2.ApplyEventarcAlphaChannelRequest() | ||
if Primitive.to_proto(self.name): | ||
request.resource.name = Primitive.to_proto(self.name) | ||
|
||
if Primitive.to_proto(self.provider): | ||
request.resource.provider = Primitive.to_proto(self.provider) | ||
|
||
if Primitive.to_proto(self.crypto_key_name): | ||
request.resource.crypto_key_name = Primitive.to_proto(self.crypto_key_name) | ||
|
||
if Primitive.to_proto(self.project): | ||
request.resource.project = Primitive.to_proto(self.project) | ||
|
||
if Primitive.to_proto(self.location): | ||
request.resource.location = Primitive.to_proto(self.location) | ||
|
||
request.service_account_file = self.service_account_file | ||
|
||
response = stub.ApplyEventarcAlphaChannel(request) | ||
self.name = Primitive.from_proto(response.name) | ||
self.uid = Primitive.from_proto(response.uid) | ||
self.create_time = Primitive.from_proto(response.create_time) | ||
self.update_time = Primitive.from_proto(response.update_time) | ||
self.provider = Primitive.from_proto(response.provider) | ||
self.pubsub_topic = Primitive.from_proto(response.pubsub_topic) | ||
self.state = ChannelStateEnum.from_proto(response.state) | ||
self.activation_token = Primitive.from_proto(response.activation_token) | ||
self.crypto_key_name = Primitive.from_proto(response.crypto_key_name) | ||
self.project = Primitive.from_proto(response.project) | ||
self.location = Primitive.from_proto(response.location) | ||
|
||
def delete(self): | ||
stub = channel_pb2_grpc.EventarcAlphaChannelServiceStub(channel.Channel()) | ||
request = channel_pb2.DeleteEventarcAlphaChannelRequest() | ||
request.service_account_file = self.service_account_file | ||
if Primitive.to_proto(self.name): | ||
request.resource.name = Primitive.to_proto(self.name) | ||
|
||
if Primitive.to_proto(self.provider): | ||
request.resource.provider = Primitive.to_proto(self.provider) | ||
|
||
if Primitive.to_proto(self.crypto_key_name): | ||
request.resource.crypto_key_name = Primitive.to_proto(self.crypto_key_name) | ||
|
||
if Primitive.to_proto(self.project): | ||
request.resource.project = Primitive.to_proto(self.project) | ||
|
||
if Primitive.to_proto(self.location): | ||
request.resource.location = Primitive.to_proto(self.location) | ||
|
||
response = stub.DeleteEventarcAlphaChannel(request) | ||
|
||
@classmethod | ||
def list(self, project, location, service_account_file=""): | ||
stub = channel_pb2_grpc.EventarcAlphaChannelServiceStub(channel.Channel()) | ||
request = channel_pb2.ListEventarcAlphaChannelRequest() | ||
request.service_account_file = service_account_file | ||
request.Project = project | ||
|
||
request.Location = location | ||
|
||
return stub.ListEventarcAlphaChannel(request).items | ||
|
||
def to_proto(self): | ||
resource = channel_pb2.EventarcAlphaChannel() | ||
if Primitive.to_proto(self.name): | ||
resource.name = Primitive.to_proto(self.name) | ||
if Primitive.to_proto(self.provider): | ||
resource.provider = Primitive.to_proto(self.provider) | ||
if Primitive.to_proto(self.crypto_key_name): | ||
resource.crypto_key_name = Primitive.to_proto(self.crypto_key_name) | ||
if Primitive.to_proto(self.project): | ||
resource.project = Primitive.to_proto(self.project) | ||
if Primitive.to_proto(self.location): | ||
resource.location = Primitive.to_proto(self.location) | ||
return resource | ||
|
||
|
||
class ChannelStateEnum(object): | ||
@classmethod | ||
def to_proto(self, resource): | ||
if not resource: | ||
return resource | ||
return channel_pb2.EventarcAlphaChannelStateEnum.Value( | ||
"EventarcAlphaChannelStateEnum%s" % resource | ||
) | ||
|
||
@classmethod | ||
def from_proto(self, resource): | ||
if not resource: | ||
return resource | ||
return channel_pb2.EventarcAlphaChannelStateEnum.Name(resource)[ | ||
len("EventarcAlphaChannelStateEnum") : | ||
] | ||
|
||
|
||
class Primitive(object): | ||
@classmethod | ||
def to_proto(self, s): | ||
if not s: | ||
return "" | ||
return s | ||
|
||
@classmethod | ||
def from_proto(self, s): | ||
return s |
Oops, something went wrong.