Skip to content

Commit

Permalink
Automated DCL import.
Browse files Browse the repository at this point in the history
  - bd317ae7ef97aa072acfcd78d3cdcbb006f80a72 Automatic import from cloud_mmv2_dcl_20240109_1831_RC00 by DCL Team <[email protected]>

GitOrigin-RevId: bd317ae7ef97aa072acfcd78d3cdcbb006f80a72
  • Loading branch information
DCL Team authored and copybara-github committed Jan 10, 2024
1 parent 88e5e9d commit 17a3a9a
Show file tree
Hide file tree
Showing 13 changed files with 2,714 additions and 899 deletions.
32 changes: 25 additions & 7 deletions python/proto/cloudbuildv2/alpha/connection.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ message Cloudbuildv2AlphaConnection {
Cloudbuildv2AlphaConnectionGithubEnterpriseConfig github_enterprise_config = 5;
Cloudbuildv2AlphaConnectionGitlabConfig gitlab_config = 6;
Cloudbuildv2AlphaConnectionBitbucketDataCenterConfig bitbucket_data_center_config = 7;
Cloudbuildv2AlphaConnectionInstallationState installation_state = 8;
bool disabled = 9;
bool reconciling = 10;
map<string, string> annotations = 11;
string etag = 12;
string project = 13;
string location = 14;
Cloudbuildv2AlphaConnectionBitbucketCloudConfig bitbucket_cloud_config = 8;
Cloudbuildv2AlphaConnectionInstallationState installation_state = 9;
bool disabled = 10;
bool reconciling = 11;
map<string, string> annotations = 12;
string etag = 13;
string project = 14;
string location = 15;
}

message Cloudbuildv2AlphaConnectionGithubConfig {
Expand Down Expand Up @@ -120,6 +121,23 @@ message Cloudbuildv2AlphaConnectionBitbucketDataCenterConfigServiceDirectoryConf
string service = 1;
}

message Cloudbuildv2AlphaConnectionBitbucketCloudConfig {
string workspace = 1;
string webhook_secret_secret_version = 2;
Cloudbuildv2AlphaConnectionBitbucketCloudConfigReadAuthorizerCredential read_authorizer_credential = 3;
Cloudbuildv2AlphaConnectionBitbucketCloudConfigAuthorizerCredential authorizer_credential = 4;
}

message Cloudbuildv2AlphaConnectionBitbucketCloudConfigReadAuthorizerCredential {
string user_token_secret_version = 1;
string username = 2;
}

message Cloudbuildv2AlphaConnectionBitbucketCloudConfigAuthorizerCredential {
string user_token_secret_version = 1;
string username = 2;
}

message Cloudbuildv2AlphaConnectionInstallationState {
Cloudbuildv2AlphaConnectionInstallationStateStageEnum stage = 1;
string message = 2;
Expand Down
205 changes: 205 additions & 0 deletions python/services/cloudbuildv2/alpha/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
github_enterprise_config: dict = None,
gitlab_config: dict = None,
bitbucket_data_center_config: dict = None,
bitbucket_cloud_config: dict = None,
installation_state: dict = None,
disabled: bool = None,
reconciling: bool = None,
Expand All @@ -43,6 +44,7 @@ def __init__(
self.github_enterprise_config = github_enterprise_config
self.gitlab_config = gitlab_config
self.bitbucket_data_center_config = bitbucket_data_center_config
self.bitbucket_cloud_config = bitbucket_cloud_config
self.disabled = disabled
self.annotations = annotations
self.project = project
Expand Down Expand Up @@ -85,6 +87,12 @@ def apply(self):
)
else:
request.resource.ClearField("bitbucket_data_center_config")
if ConnectionBitbucketCloudConfig.to_proto(self.bitbucket_cloud_config):
request.resource.bitbucket_cloud_config.CopyFrom(
ConnectionBitbucketCloudConfig.to_proto(self.bitbucket_cloud_config)
)
else:
request.resource.ClearField("bitbucket_cloud_config")
if Primitive.to_proto(self.disabled):
request.resource.disabled = Primitive.to_proto(self.disabled)

Expand Down Expand Up @@ -113,6 +121,9 @@ def apply(self):
response.bitbucket_data_center_config
)
)
self.bitbucket_cloud_config = ConnectionBitbucketCloudConfig.from_proto(
response.bitbucket_cloud_config
)
self.installation_state = ConnectionInstallationState.from_proto(
response.installation_state
)
Expand Down Expand Up @@ -160,6 +171,12 @@ def delete(self):
)
else:
request.resource.ClearField("bitbucket_data_center_config")
if ConnectionBitbucketCloudConfig.to_proto(self.bitbucket_cloud_config):
request.resource.bitbucket_cloud_config.CopyFrom(
ConnectionBitbucketCloudConfig.to_proto(self.bitbucket_cloud_config)
)
else:
request.resource.ClearField("bitbucket_cloud_config")
if Primitive.to_proto(self.disabled):
request.resource.disabled = Primitive.to_proto(self.disabled)

Expand Down Expand Up @@ -219,6 +236,12 @@ def to_proto(self):
)
else:
resource.ClearField("bitbucket_data_center_config")
if ConnectionBitbucketCloudConfig.to_proto(self.bitbucket_cloud_config):
resource.bitbucket_cloud_config.CopyFrom(
ConnectionBitbucketCloudConfig.to_proto(self.bitbucket_cloud_config)
)
else:
resource.ClearField("bitbucket_cloud_config")
if Primitive.to_proto(self.disabled):
resource.disabled = Primitive.to_proto(self.disabled)
if Primitive.to_proto(self.annotations):
Expand Down Expand Up @@ -967,6 +990,188 @@ def from_proto(self, resources):
]


class ConnectionBitbucketCloudConfig(object):
def __init__(
self,
workspace: str = None,
webhook_secret_secret_version: str = None,
read_authorizer_credential: dict = None,
authorizer_credential: dict = None,
):
self.workspace = workspace
self.webhook_secret_secret_version = webhook_secret_secret_version
self.read_authorizer_credential = read_authorizer_credential
self.authorizer_credential = authorizer_credential

@classmethod
def to_proto(self, resource):
if not resource:
return None

res = connection_pb2.Cloudbuildv2AlphaConnectionBitbucketCloudConfig()
if Primitive.to_proto(resource.workspace):
res.workspace = Primitive.to_proto(resource.workspace)
if Primitive.to_proto(resource.webhook_secret_secret_version):
res.webhook_secret_secret_version = Primitive.to_proto(
resource.webhook_secret_secret_version
)
if ConnectionBitbucketCloudConfigReadAuthorizerCredential.to_proto(
resource.read_authorizer_credential
):
res.read_authorizer_credential.CopyFrom(
ConnectionBitbucketCloudConfigReadAuthorizerCredential.to_proto(
resource.read_authorizer_credential
)
)
else:
res.ClearField("read_authorizer_credential")
if ConnectionBitbucketCloudConfigAuthorizerCredential.to_proto(
resource.authorizer_credential
):
res.authorizer_credential.CopyFrom(
ConnectionBitbucketCloudConfigAuthorizerCredential.to_proto(
resource.authorizer_credential
)
)
else:
res.ClearField("authorizer_credential")
return res

@classmethod
def from_proto(self, resource):
if not resource:
return None

return ConnectionBitbucketCloudConfig(
workspace=Primitive.from_proto(resource.workspace),
webhook_secret_secret_version=Primitive.from_proto(
resource.webhook_secret_secret_version
),
read_authorizer_credential=ConnectionBitbucketCloudConfigReadAuthorizerCredential.from_proto(
resource.read_authorizer_credential
),
authorizer_credential=ConnectionBitbucketCloudConfigAuthorizerCredential.from_proto(
resource.authorizer_credential
),
)


class ConnectionBitbucketCloudConfigArray(object):
@classmethod
def to_proto(self, resources):
if not resources:
return resources
return [ConnectionBitbucketCloudConfig.to_proto(i) for i in resources]

@classmethod
def from_proto(self, resources):
return [ConnectionBitbucketCloudConfig.from_proto(i) for i in resources]


class ConnectionBitbucketCloudConfigReadAuthorizerCredential(object):
def __init__(self, user_token_secret_version: str = None, username: str = None):
self.user_token_secret_version = user_token_secret_version
self.username = username

@classmethod
def to_proto(self, resource):
if not resource:
return None

res = (
connection_pb2.Cloudbuildv2AlphaConnectionBitbucketCloudConfigReadAuthorizerCredential()
)
if Primitive.to_proto(resource.user_token_secret_version):
res.user_token_secret_version = Primitive.to_proto(
resource.user_token_secret_version
)
if Primitive.to_proto(resource.username):
res.username = Primitive.to_proto(resource.username)
return res

@classmethod
def from_proto(self, resource):
if not resource:
return None

return ConnectionBitbucketCloudConfigReadAuthorizerCredential(
user_token_secret_version=Primitive.from_proto(
resource.user_token_secret_version
),
username=Primitive.from_proto(resource.username),
)


class ConnectionBitbucketCloudConfigReadAuthorizerCredentialArray(object):
@classmethod
def to_proto(self, resources):
if not resources:
return resources
return [
ConnectionBitbucketCloudConfigReadAuthorizerCredential.to_proto(i)
for i in resources
]

@classmethod
def from_proto(self, resources):
return [
ConnectionBitbucketCloudConfigReadAuthorizerCredential.from_proto(i)
for i in resources
]


class ConnectionBitbucketCloudConfigAuthorizerCredential(object):
def __init__(self, user_token_secret_version: str = None, username: str = None):
self.user_token_secret_version = user_token_secret_version
self.username = username

@classmethod
def to_proto(self, resource):
if not resource:
return None

res = (
connection_pb2.Cloudbuildv2AlphaConnectionBitbucketCloudConfigAuthorizerCredential()
)
if Primitive.to_proto(resource.user_token_secret_version):
res.user_token_secret_version = Primitive.to_proto(
resource.user_token_secret_version
)
if Primitive.to_proto(resource.username):
res.username = Primitive.to_proto(resource.username)
return res

@classmethod
def from_proto(self, resource):
if not resource:
return None

return ConnectionBitbucketCloudConfigAuthorizerCredential(
user_token_secret_version=Primitive.from_proto(
resource.user_token_secret_version
),
username=Primitive.from_proto(resource.username),
)


class ConnectionBitbucketCloudConfigAuthorizerCredentialArray(object):
@classmethod
def to_proto(self, resources):
if not resources:
return resources
return [
ConnectionBitbucketCloudConfigAuthorizerCredential.to_proto(i)
for i in resources
]

@classmethod
def from_proto(self, resources):
return [
ConnectionBitbucketCloudConfigAuthorizerCredential.from_proto(i)
for i in resources
]


class ConnectionInstallationState(object):
def __init__(self, stage: str = None, message: str = None, action_uri: str = None):
self.stage = stage
Expand Down
Loading

0 comments on commit 17a3a9a

Please sign in to comment.