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,33 @@
# -*- 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.
"""Manages essential contacts."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class EssentialContacts(base.Group):
"""Manage Essential Contacts.
Essential Contacts can be set on a Cloud resource to receive communications
from Google Cloud regarding that resource.
"""
category = base.MANAGEMENT_TOOLS_CATEGORY

View File

@@ -0,0 +1,88 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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.
"""Command to compute Essential Contacts for a resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.essential_contacts import contacts
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.essential_contacts import flags
from googlecloudsdk.command_lib.essential_contacts import util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class Compute(base.ListCommand):
r"""Compute the essential contacts that are subscribed to the specified notification categories for a resource.
This command will return the contacts subscribed to any of the notification
categories that have been set on the requested resource or any of its
ancestors.
## EXAMPLES
To compute contacts subscribed to the technical category for the current
project, run:
$ {command} --notification-categories=technical
To compute contacts subscribed to the product-updates or billing categories
for the folder with id ``123'', run:
$ {command} --notification-categories=product-updates,billing
--folder=123
To compute contacts subscribed to the legal category for the organization with
id ``456'', run:
$ {command} --notification-categories=legal --organization=456
"""
@staticmethod
def _GetNotificationCategoryEnumByParentType(parent_name):
"""Gets the NotificationCategory enum to cast the args as based on the type of parent resource arg."""
if parent_name.startswith('folders'):
return contacts.GetMessages(
).EssentialcontactsFoldersContactsComputeRequest.NotificationCategoriesValueValuesEnum
if parent_name.startswith('organizations'):
return contacts.GetMessages(
).EssentialcontactsOrganizationsContactsComputeRequest.NotificationCategoriesValueValuesEnum
return contacts.GetMessages(
).EssentialcontactsProjectsContactsComputeRequest.NotificationCategoriesValueValuesEnum
@staticmethod
def Args(parser):
"""Adds command-specific args."""
flags.AddNotificationCategoriesArg(
parser, contacts.GetContactNotificationCategoryEnum(), required=True)
flags.AddParentArgs(parser)
base.URI_FLAG.RemoveFromParser(parser)
def Run(self, args):
"""Runs the compute contacts command."""
parent_name = util.GetParent(args)
notification_category_enum = self._GetNotificationCategoryEnumByParentType(
parent_name)
categories = util.GetNotificationCategories(args,
notification_category_enum)
client = contacts.ContactsClient()
return client.Compute(
parent_name, categories, limit=args.limit, page_size=args.page_size)

View File

@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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.
"""Command to create an Essential Contact."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.essential_contacts import contacts
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.essential_contacts import flags
from googlecloudsdk.command_lib.essential_contacts import util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class Create(base.CreateCommand):
r"""Create an essential contact.
## EXAMPLES
To create a contact in the current project, run:
$ {command} --email=contact-email@example.com
--notification-categories=technical,product-updates --language=en-US
To create a contact in the folder with id ``456'', run:
$ {command} --email=contact-email@example.com
--notification-categories=technical,product-updates --language=en-US
--folder=456
To create a contact in the organization with id ``456'', run:
$ {command} --email=contact-email@example.com
--notification-categories=technical,product-updates --language=en-US
--organization=456
"""
@staticmethod
def Args(parser):
"""Adds command-specific args."""
flags.AddEmailArg(parser, required=True)
flags.AddNotificationCategoriesArg(
parser, contacts.GetContactNotificationCategoryEnum(), required=True)
flags.AddLanugageArg(parser, required=True)
flags.AddParentArgs(parser)
def Run(self, args):
"""Runs the create command."""
parent_name = util.GetParent(args)
categories = util.GetNotificationCategories(
args, contacts.GetContactNotificationCategoryEnum())
client = contacts.ContactsClient()
return client.Create(parent_name, args.email, categories, args.language)

View File

@@ -0,0 +1,59 @@
# -*- 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.
"""Command to delete a Contact from Essential Contacts."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.essential_contacts import contacts
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.essential_contacts import flags
from googlecloudsdk.command_lib.essential_contacts import util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class Delete(base.DeleteCommand):
"""Delete an essential contact.
## EXAMPLES
To delete the contact with id ``123'' in the current project, run:
$ {command} 123
To delete the contact with id ``123'' in the folder with id ``456'', run:
$ {command} 123 --folder=456
To delete the contact with id ``123'' in the organization with id ``456'',
run:
$ {command} 123 --organization=456
"""
@staticmethod
def Args(parser):
"""Adds command-specific args."""
flags.AddContactIdArg(parser, help_text='id of contact to delete.')
flags.AddParentArgs(parser)
def Run(self, args):
"""Runs the delete command."""
contact_name = util.GetContactName(args)
client = contacts.ContactsClient()
return client.Delete(contact_name)

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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.
"""Command to describe a contact from Essential Contacts."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.essential_contacts import contacts
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.essential_contacts import flags
from googlecloudsdk.command_lib.essential_contacts import util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class Describe(base.DescribeCommand):
"""Describe an essential contact.
## EXAMPLES
To describe the contact with id ``123'' in the current project, run:
$ {command} 123
To describe the contact with id ``123'' in the folder with id ``456'', run:
$ {command} 123 --folder=456
To describe the contact with id ``123'' in the organization with id ``456'',
run:
$ {command} 123 --organization=456
"""
@staticmethod
def Args(parser):
"""Adds command-specific args."""
flags.AddContactIdArg(parser, help_text='id of contact to describe.')
flags.AddParentArgs(parser)
def Run(self, args):
"""Runs the describe command."""
contact_name = util.GetContactName(args)
client = contacts.ContactsClient()
return client.Describe(contact_name)

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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.
"""Command to list essential contacts for a resource."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.essential_contacts import contacts
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.essential_contacts import flags
from googlecloudsdk.command_lib.essential_contacts import util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class List(base.ListCommand):
"""List essential contacts for a resource.
## EXAMPLES
To list the contacts set on the current project:
$ {command} [--page_size=10] [--limit=20]
To list the contacts set on the folder with id ``456'', run:
$ {command} --folder=456 [--page_size=10] [--limit=20]
To list the contacts set on the organization with id ``456'', run:
$ {command} --organization=456 [--page_size=10] [--limit=20]
"""
@staticmethod
def Args(parser):
"""Adds command-specific args."""
flags.AddParentArgs(parser)
base.URI_FLAG.RemoveFromParser(parser)
def Run(self, args):
"""Runs the list command."""
parent_name = util.GetParent(args)
client = contacts.ContactsClient()
return client.List(parent_name, limit=args.limit, page_size=args.page_size)

View File

@@ -0,0 +1,74 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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.
"""Command to update an Essential Contact."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.essential_contacts import contacts
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions
from googlecloudsdk.command_lib.essential_contacts import flags
from googlecloudsdk.command_lib.essential_contacts import util
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA,
base.ReleaseTrack.GA)
@base.UniverseCompatible
class Update(base.UpdateCommand):
r"""Update an essential contact.
## EXAMPLES
To update the notification category subscriptions for the contact with id
``123'' in the current project, run:
$ {command} 123 --notification-categories=legal,suspension
To update the language preference for the contact with id ``123'' in the
folder with id ``456'', run:
$ {command} 123 --language=es --folder=456
To update the notification category subscriptions and language preference for
the contact with id ``123'' in the organization with id ``456'', run:
$ {command} 123 --notification-categories=legal --language=en-US
--organization=456
"""
@staticmethod
def Args(parser):
"""Adds command-specific args."""
flags.AddContactIdArg(parser)
flags.AddNotificationCategoriesArg(
parser, contacts.GetContactNotificationCategoryEnum())
flags.AddLanugageArg(parser)
flags.AddParentArgs(parser)
def Run(self, args):
"""Runs the update command."""
contact_name = util.GetContactName(args)
categories = util.GetNotificationCategories(
args, contacts.GetContactNotificationCategoryEnum())
language = args.language
if not language and not categories:
raise exceptions.MinimumArgumentException(
['notification-categories', 'language'])
client = contacts.ContactsClient()
return client.Update(contact_name, categories, language)