feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.

View File

@@ -0,0 +1,116 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Access approval requests API helper."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from apitools.base.py import list_pager
from googlecloudsdk.api_lib.util import apis
def Approve(name):
"""Approve an approval request."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsApprovalRequestsApproveRequest(
name=name)
return client.organizations_approvalRequests.Approve(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersApprovalRequestsApproveRequest(name=name)
return client.folders_approvalRequests.Approve(req)
req = msgs.AccessapprovalProjectsApprovalRequestsApproveRequest(name=name)
return client.projects_approvalRequests.Approve(req)
def Dismiss(name):
"""Dismiss an approval request."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsApprovalRequestsDismissRequest(
name=name)
return client.organizations_approvalRequests.Dismiss(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersApprovalRequestsDismissRequest(name=name)
return client.folders_approvalRequests.Dismiss(req)
req = msgs.AccessapprovalProjectsApprovalRequestsDismissRequest(name=name)
return client.projects_approvalRequests.Dismiss(req)
def Invalidate(name):
"""Invalidate an approval request."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsApprovalRequestsInvalidateRequest(
name=name)
return client.organizations_approvalRequests.Invalidate(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersApprovalRequestsInvalidateRequest(name=name)
return client.folders_approvalRequests.Invalidate(req)
req = msgs.AccessapprovalProjectsApprovalRequestsInvalidateRequest(name=name)
return client.projects_approvalRequests.Invalidate(req)
def Get(name):
"""Get an approval request by name."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsApprovalRequestsGetRequest(name=name)
return client.organizations_approvalRequests.Get(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersApprovalRequestsGetRequest(name=name)
return client.folders_approvalRequests.Get(req)
req = msgs.AccessapprovalProjectsApprovalRequestsGetRequest(name=name)
return client.projects_approvalRequests.Get(req)
def List(parent, filter=None):
"""List approval requests for the parent resource."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
req = None
svc = None
if 'organizations/' in parent:
req = msgs.AccessapprovalOrganizationsApprovalRequestsListRequest(
parent=parent)
svc = client.organizations_approvalRequests
elif 'folders/' in parent:
req = msgs.AccessapprovalFoldersApprovalRequestsListRequest(parent=parent)
svc = client.folders_approvalRequests
else:
req = msgs.AccessapprovalProjectsApprovalRequestsListRequest(parent=parent)
svc = client.projects_approvalRequests
if filter:
req.filter = filter
else:
req.filter = 'PENDING'
return list_pager.YieldFromList(
svc, req, field='approvalRequests', batch_size_attribute='pageSize')

View File

@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*- #
# 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.
"""Access approval service account API helper."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.util import apis
def Get(name):
"""Get the access approval service account for a resource."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsGetServiceAccountRequest(name=name)
return client.organizations.GetServiceAccount(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersGetServiceAccountRequest(name=name)
return client.folders.GetServiceAccount(req)
req = msgs.AccessapprovalProjectsGetServiceAccountRequest(name=name)
return client.projects.GetServiceAccount(req)

View File

@@ -0,0 +1,136 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Access approval settings API helper."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.util import apis
def Delete(name):
"""Delete the access approval settings for a resource."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsDeleteAccessApprovalSettingsRequest(
name=name
)
return client.organizations.DeleteAccessApprovalSettings(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersDeleteAccessApprovalSettingsRequest(
name=name
)
return client.folders.DeleteAccessApprovalSettings(req)
req = msgs.AccessapprovalProjectsDeleteAccessApprovalSettingsRequest(
name=name
)
return client.projects.DeleteAccessApprovalSettings(req)
def Get(name):
"""Get the access approval settings for a resource."""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsGetAccessApprovalSettingsRequest(
name=name
)
return client.organizations.GetAccessApprovalSettings(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersGetAccessApprovalSettingsRequest(name=name)
return client.folders.GetAccessApprovalSettings(req)
req = msgs.AccessapprovalProjectsGetAccessApprovalSettingsRequest(name=name)
return client.projects.GetAccessApprovalSettings(req)
def Update(
name,
notification_emails,
enrolled_services,
active_key_version,
preferred_request_expiration_days,
prefer_no_broad_approval_requests,
notification_pubsub_topic,
request_scope_max_width_preference,
require_customer_visible_justification,
approval_policy,
update_mask,
):
"""Update the access approval settings for a resource.
Args:
name: the settings resource name (e.g. projects/123/accessApprovalSettings)
notification_emails: list of email addresses
enrolled_services: list of services
active_key_version: KMS signing key version resource name
preferred_request_expiration_days: the default expiration time for approval
requests
prefer_no_broad_approval_requests: communicates the preference to Google
personnel to request access with as targeted a resource scope as possible
notification_pubsub_topic: A pubsub topic to which notifications relating to
approval requests should be sent
request_scope_max_width_preference: specifies broadest scope of access for
access requests without a specific method
require_customer_visible_justification: to configure if a customer visible
justification (i.e. Vector Case) is required for a Googler to create an
Access Ticket to send to the customer when attempting to access customer
resources.
approval_policy: the policy for approving requests
update_mask: which fields to update
Returns:
updated settings
"""
client = apis.GetClientInstance('accessapproval', 'v1')
msgs = apis.GetMessagesModule('accessapproval', 'v1')
settings = None
services_protos = [
msgs.EnrolledService(cloudProduct=s) for s in enrolled_services
]
settings = msgs.AccessApprovalSettings(
name=name,
enrolledServices=services_protos,
notificationEmails=notification_emails,
activeKeyVersion=active_key_version,
preferredRequestExpirationDays=preferred_request_expiration_days,
preferNoBroadApprovalRequests=prefer_no_broad_approval_requests,
notificationPubsubTopic=notification_pubsub_topic,
requestScopeMaxWidthPreference=request_scope_max_width_preference,
requireCustomerVisibleJustification=require_customer_visible_justification,
approvalPolicy=approval_policy,
)
if 'organizations/' in name:
req = msgs.AccessapprovalOrganizationsUpdateAccessApprovalSettingsRequest(
name=name, accessApprovalSettings=settings, updateMask=update_mask
)
return client.organizations.UpdateAccessApprovalSettings(req)
if 'folders/' in name:
req = msgs.AccessapprovalFoldersUpdateAccessApprovalSettingsRequest(
name=name, accessApprovalSettings=settings, updateMask=update_mask
)
return client.folders.UpdateAccessApprovalSettings(req)
req = msgs.AccessapprovalProjectsUpdateAccessApprovalSettingsRequest(
name=name, accessApprovalSettings=settings, updateMask=update_mask
)
return client.projects.UpdateAccessApprovalSettings(req)