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,30 @@
# -*- 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.
"""gcloud domains registrations configure command group."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
class DomainRegistrationAuthorizationCode(base.Group):
"""Configure Cloud Domains registrations' management, DNS or contact settings.
Commands for configuring Cloud Domains registrations' management, DNS or
contact settings.
"""
pass

View File

@@ -0,0 +1,149 @@
# -*- 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.
"""`gcloud domains registrations configure contacts` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.domains import registrations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.domains import contacts_util
from googlecloudsdk.command_lib.domains import flags
from googlecloudsdk.command_lib.domains import resource_args
from googlecloudsdk.command_lib.domains import util
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
class ConfigureContacts(base.UpdateCommand):
"""Configure contact settings of a Cloud Domains registration.
Configure registration's contact settings: email, phone number, postal
address and also contact privacy.
In some cases such changes have to be confirmed through an email sent to
the registrant before they take effect. In order to resend the email, execute
this command again.
NOTE: Please consider carefully any changes to contact privacy settings when
changing from "redacted-contact-data" to "public-contact-data."
There may be a delay in reflecting updates you make to registrant
contact information such that any changes you make to contact privacy
(including from "redacted-contact-data" to "public-contact-data")
will be applied without delay but changes to registrant contact
information may take a limited time to be publicized. This means that
changes to contact privacy from "redacted-contact-data" to
"public-contact-data" may make the previous registrant contact
data public until the modified registrant contact details are published.
## EXAMPLES
To start an interactive flow to configure contact settings for
``example.com'', run:
$ {command} example.com
To enable contact privacy for ``example.com'', run:
$ {command} example.com --contact-privacy=private-contact-data
To change contact data for ``example.com'' according to information from a
YAML file ``contacts.yaml'', run:
$ {command} example.com --contact-data-from-file=contacts.yaml
"""
@staticmethod
def Args(parser):
resource_args.AddRegistrationResourceArg(
parser, 'to configure contact settings for')
flags.AddConfigureContactsSettingsFlagsToParser(parser)
flags.AddValidateOnlyFlagToParser(parser,
'configure contact settings of the')
flags.AddAsyncFlagToParser(parser)
def CheckPendingContacts(self, client, registration_ref):
registration = client.Get(registration_ref)
return bool(registration.pendingContactSettings)
def Run(self, args):
api_version = registrations.GetApiVersionFromArgs(args)
client = registrations.RegistrationsClient(api_version)
args.registration = util.NormalizeResourceName(args.registration)
registration_ref = args.CONCEPTS.registration.Parse()
registration = client.Get(registration_ref)
util.AssertRegistrationOperational(api_version, registration)
contacts = contacts_util.ParseContactData(api_version,
args.contact_data_from_file)
contact_privacy = contacts_util.ParseContactPrivacy(api_version,
args.contact_privacy)
public_contacts_ack = contacts_util.ParsePublicContactsAck(
api_version, args.notices)
if contacts is None:
contacts = contacts_util.PromptForContacts(api_version,
registration.contactSettings)
if contact_privacy is None:
choices = list(
map(
flags.ContactPrivacyEnumMapper(client.messages).GetChoiceForEnum,
registration.supportedPrivacy))
contact_privacy = contacts_util.PromptForContactPrivacy(
api_version, choices, registration.contactSettings.privacy)
if contacts is None and contact_privacy is None:
# Nothing to update.
return None
new_privacy = contact_privacy or registration.contactSettings.privacy
privacy = client.messages.ContactSettings.PrivacyValueValuesEnum
if not public_contacts_ack and new_privacy == privacy.PUBLIC_CONTACT_DATA:
merged_contacts = contacts_util.MergeContacts(
api_version,
prev_contacts=registration.contactSettings,
new_contacts=contacts)
if registration.contactSettings.privacy != privacy.PUBLIC_CONTACT_DATA:
public_contacts_ack = contacts_util.PromptForPublicContactsUpdateAck(
registration.domainName, merged_contacts)
else:
public_contacts_ack = contacts_util.PromptForPublicContactsAck(
registration.domainName, merged_contacts)
response = client.ConfigureContacts(
registration_ref,
contacts,
contact_privacy,
public_contacts_ack,
validate_only=args.validate_only)
if args.validate_only:
log.status.Print('The command will not have any effect because '
'validate-only flag is present.')
else:
response = util.WaitForOperation(api_version, response, args.async_)
note = None
if not args.async_ and self.CheckPendingContacts(client,
registration_ref):
note = ('Note:\nThe contact settings are currently pending.\nIn order '
'to finalize the update you need to confirm the change.\nAn '
'email with instructions has been sent to the registrant.')
log.UpdatedResource(
registration_ref.Name(), 'registration', args.async_, details=note)
return response

View File

@@ -0,0 +1,155 @@
# -*- 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.
"""`gcloud domains registrations configure dns` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.domains import registrations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.domains import dns_util
from googlecloudsdk.command_lib.domains import flags
from googlecloudsdk.command_lib.domains import resource_args
from googlecloudsdk.command_lib.domains import util
from googlecloudsdk.core import exceptions
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
class ConfigureDNS(base.UpdateCommand):
"""Configure DNS settings of a Cloud Domains registration.
Configure DNS settings of a Cloud Domains registration.
In most cases, this command is used for changing the authoritative name
servers and DNSSEC options for the given domain. However, advanced options
like glue records are available.
## EXAMPLES
To start an interactive flow to configure DNS settings for ``example.com'',
run:
$ {command} example.com
To use Cloud DNS managed-zone ``example-zone'' for ``example.com'', run:
$ {command} example.com --cloud-dns-zone=example-zone
DNSSEC will not be enabled as it may not be safe to enable it (e.g. when the
Cloud DNS managed-zone was signed less than 24h ago).
To use a signed Cloud DNS managed-zone ``example-zone'' for ``example.com''
and enable DNSSEC, run:
$ {command} example.com --cloud-dns-zone=example-zone --no-disable-dnssec
To change DNS settings for ``example.com'' according to information from a
YAML file ``dns_settings.yaml'', run:
$ {command} example.com --dns-settings-from-file=dns_settings.yaml
To disable DNSSEC, run:
$ {command} example.com --disable-dnssec
"""
@staticmethod
def Args(parser):
resource_args.AddRegistrationResourceArg(parser,
'to configure DNS settings for')
flags.AddConfigureDNSSettingsFlagsToParser(parser)
flags.AddValidateOnlyFlagToParser(parser, 'configure DNS settings of the')
flags.AddAsyncFlagToParser(parser)
def Run(self, args):
api_version = registrations.GetApiVersionFromArgs(args)
client = registrations.RegistrationsClient(api_version)
args.registration = util.NormalizeResourceName(args.registration)
registration_ref = args.CONCEPTS.registration.Parse()
dnssec_flag_provided = args.IsSpecified('disable_dnssec')
if dnssec_flag_provided and args.dns_settings_from_file:
raise exceptions.Error(
'argument --disable-dnssec: At most one of '
'--dns-settings-from-file | --disable-dnssec can be specified.')
registration = client.Get(registration_ref)
util.AssertRegistrationOperational(api_version, registration)
dnssec_update = dns_util.DNSSECUpdate.NO_CHANGE
if dnssec_flag_provided and args.disable_dnssec:
dnssec_update = dns_util.DNSSECUpdate.DISABLE
elif dnssec_flag_provided and not args.disable_dnssec:
dnssec_update = dns_util.DNSSECUpdate.ENABLE
dns_settings, update_mask = dns_util.ParseDNSSettings(
api_version,
args.name_servers,
args.cloud_dns_zone,
args.use_google_domains_dns,
args.dns_settings_from_file,
registration_ref.registrationsId,
dnssec_update=dnssec_update,
dns_settings=registration.dnsSettings,
)
if dns_settings is None:
dns_settings, update_mask = dns_util.PromptForNameServers(
api_version,
registration_ref.registrationsId,
dnssec_update=dnssec_update,
dns_settings=registration.dnsSettings,
)
if dns_settings is None:
return None
if registration.dnsSettings.glueRecords and not update_mask.glue_records:
# It's ok to leave Glue records while changing name servers.
log.status.Print(
'Glue records will not be cleared. If you want to clear '
'them, use --dns-settings-from-file flag.'
)
ds_records_present = dns_util.DnssecEnabled(registration.dnsSettings)
new_ds_records = dns_util.DnssecEnabled(dns_settings)
name_servers_changed = (
update_mask.name_servers
and not dns_util.NameServersEquivalent(
registration.dnsSettings, dns_settings
)
)
if (ds_records_present or new_ds_records) and name_servers_changed:
log.warning('Name servers should not be changed if DS '
'records are present or added. Disable DNSSEC first and wait '
'24 hours before you change name servers. Otherwise '
'your domain may stop serving.')
if not args.unsafe_dns_update:
dns_util.PromptForUnsafeDnsUpdate()
response = client.ConfigureDNS(
registration_ref,
dns_settings,
update_mask,
validate_only=args.validate_only)
if args.validate_only:
log.status.Print('The command will not have any effect because '
'validate-only flag is present.')
else:
response = util.WaitForOperation(api_version, response, args.async_)
log.UpdatedResource(registration_ref.Name(), 'registration', args.async_)
return response

View File

@@ -0,0 +1,90 @@
# -*- 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.
"""`gcloud domains registrations configure management` command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.domains import registrations
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.domains import flags
from googlecloudsdk.command_lib.domains import resource_args
from googlecloudsdk.command_lib.domains import util
from googlecloudsdk.core import log
@base.DefaultUniverseOnly
class ConfigureManagement(base.UpdateCommand):
"""Configure management settings of a Cloud Domains registration.
Configure management settings of a registration. This includes settings
related to transfers, billing and renewals of a registration.
## EXAMPLES
To start an interactive flow to configure management settings for
``example.com'', run:
$ {command} example.com
To unlock a transfer lock of a registration for ``example.com'', run:
$ {command} example.com --transfer-lock-state=unlocked
To disable automatic renewals for ``example.com'', run:
$ {command} example.com --preferred-renewal-method=renewal-disabled
"""
@staticmethod
def Args(parser):
resource_args.AddRegistrationResourceArg(
parser, 'to configure management settings for')
flags.AddManagementSettingsFlagsToParser(parser)
flags.AddAsyncFlagToParser(parser)
def Run(self, args):
api_version = registrations.GetApiVersionFromArgs(args)
client = registrations.RegistrationsClient(api_version)
args.registration = util.NormalizeResourceName(args.registration)
registration_ref = args.CONCEPTS.registration.Parse()
registration = client.Get(registration_ref)
util.AssertRegistrationOperational(api_version, registration)
transfer_lock_state = util.ParseTransferLockState(api_version,
args.transfer_lock_state)
renewal_method = util.ParseRenewalMethod(
api_version, args.preferred_renewal_method
)
if transfer_lock_state is None and renewal_method is None:
transfer_lock_state = util.PromptForTransferLockState(
api_version, registration.managementSettings.transferLockState)
renewal_method = util.PromptForRenewalMethod(
api_version, registration.managementSettings.preferredRenewalMethod
)
if transfer_lock_state is None and renewal_method is None:
return None
response = client.ConfigureManagement(
registration_ref, transfer_lock_state, renewal_method
)
response = util.WaitForOperation(api_version, response, args.async_)
log.UpdatedResource(registration_ref.Name(), 'registration', args.async_)
return response