Beispiel #1
0
    def Run(self, args):
        client = registrations.RegistrationsClient()
        args.registration = util.NormalizeResourceName(args.registration)
        registration_ref = args.CONCEPTS.registration.Parse()

        registration = client.Get(registration_ref)
        util.AssertRegistrationOperational(registration)

        contacts = contacts_util.ParseContactData(args.contact_data_from_file)
        contact_privacy = contacts_util.ParseContactPrivacy(
            args.contact_privacy)
        public_contacts_ack = contacts_util.ParsePublicContactsAck(
            args.notices)

        if contacts is None:
            contacts = contacts_util.PromptForContacts(
                registration.contactSettings)

        if contact_privacy is None:
            choices = list(
                map(flags.CONTACT_PRIVACY_ENUM_MAPPER.GetChoiceForEnum,
                    registration.supportedPrivacy))
            contact_privacy = contacts_util.PromptForContactPrivacy(
                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
        if not public_contacts_ack and new_privacy == client.messages.ContactSettings.PrivacyValueValuesEnum.PUBLIC_CONTACT_DATA:
            merged_contacts = contacts_util.MergeContacts(
                prev_contacts=registration.contactSettings,
                new_contacts=contacts)
            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(response, args.async_)
            note = None
            if not args.async_ and self.CheckPendingContacts(registration_ref):
                note = (
                    'Note:\nThe contact settings are currently pending.\nIn order '
                    'to finalize the update you need to confirm the '
                    'change using an email sent to the registrant.')
            log.UpdatedResource(registration_ref.Name(),
                                'registration',
                                args.async_,
                                details=note)

        return response
Beispiel #2
0
  def Run(self, args):
    client = registrations.RegistrationsClient()
    args.registration = util.NormalizeResourceName(args.registration)
    registration_ref = args.CONCEPTS.registration.Parse()
    if args.disable_dnssec and args.dns_settings_from_file:
      raise exceptions.Error(
          'argument --disable-dnssec: At most one of '
          '--dns-settings-from-file | --disable-dnssec may be specified.')

    registration = client.Get(registration_ref)
    util.AssertRegistrationOperational(registration)

    dns_settings, updated = dns_util.ParseDNSSettings(
        args.name_servers,
        args.cloud_dns_zone,
        args.use_google_domains_dns,
        args.dns_settings_from_file,
        registration_ref.registrationsId,
        enable_dnssec=not args.disable_dnssec,
        dns_settings=registration.dnsSettings)

    if dns_settings is None:
      dns_settings, updated = dns_util.PromptForNameServers(
          registration_ref.registrationsId,
          enable_dnssec=not args.disable_dnssec,
          dns_settings=registration.dnsSettings)
      if dns_settings is None:
        return None

    if registration.dnsSettings.glueRecords and not updated.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)
    name_servers_changed = updated.dns_provider and not dns_util.NameServersEquivalent(
        registration.dnsSettings, dns_settings)
    if ds_records_present and name_servers_changed:
      log.warning('Name servers should not be changed if Ds '
                  'records are present. 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,
        updated,
        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(response, args.async_)
      log.UpdatedResource(registration_ref.Name(), 'registration', args.async_)
    return response
Beispiel #3
0
    def Run(self, args):
        """Run reset authorization code command."""
        client = registrations.RegistrationsClient()
        args.registration = util.NormalizeResourceName(args.registration)
        registration_ref = args.CONCEPTS.registration.Parse()

        registration = client.Get(registration_ref)
        util.AssertRegistrationOperational(registration)

        return client.ResetAuthorizationCode(registration_ref)
Beispiel #4
0
    def Run(self, args):
        """Run get authorization code command."""
        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)

        return client.RetrieveAuthorizationCode(registration_ref)
Beispiel #5
0
  def Run(self, args):
    client = registrations.RegistrationsClient()
    args.registration = util.NormalizeResourceName(args.registration)
    registration_ref = args.CONCEPTS.registration.Parse()

    registration = client.Get(registration_ref)
    util.AssertRegistrationOperational(registration)

    transfer_lock_state = util.ParseTransferLockState(args.transfer_lock_state)
    if transfer_lock_state is None:
      transfer_lock_state = util.PromptForTransferLockState(
          registration.managementSettings.transferLockState)
      if transfer_lock_state is None:
        return None

    response = client.ConfigureManagement(registration_ref, transfer_lock_state)

    response = util.WaitForOperation(response, args.async_)
    log.UpdatedResource(registration_ref.Name(), 'registration', args.async_)
    return response