Example #1
0
    def Create(self, args, enable_certificate_management=False):
        client = api_client.GetApiClientForTrack(self.ReleaseTrack())

        if enable_certificate_management:
            domains_util.ValidateCertificateArgs(args.certificate_id,
                                                 args.certificate_management)

            if not args.certificate_management:
                if not args.certificate_id:
                    args.certificate_management = 'automatic'
                else:
                    args.certificate_management = 'manual'

            management_type = domains_util.ParseCertificateManagement(
                client.messages, args.certificate_management)

            mapping = client.CreateDomainMapping(args.domain,
                                                 args.certificate_id,
                                                 management_type)
        else:
            mapping = client.CreateDomainMapping(args.domain,
                                                 args.certificate_id)
        log.CreatedResource(args.domain)

        log.status.Print(
            'Please add the following entries to your domain registrar.'
            ' DNS changes can require up to 24 hours to take effect.')
        return mapping
Example #2
0
    def Run(self, args):
        client = api_client.GetApiClientForTrack(self.ReleaseTrack())

        domains_util.ValidateCertificateArgsForUpdate(
            args.certificate_id, args.no_certificate_id,
            args.certificate_management)
        if (not args.certificate_management
                and (args.certificate_id or args.no_certificate_id)):
            args.certificate_management = 'manual'

        if (args.certificate_management.upper() == 'manual'
                and not args.certificate_id and not args.no_certificate_id):
            args.no_certificate_id = True

        management_type = domains_util.ParseCertificateManagement(
            client.messages, args.certificate_management)
        mapping = client.UpdateDomainMapping(args.domain, args.certificate_id,
                                             args.no_certificate_id,
                                             management_type)
        log.UpdatedResource(args.domain)
        return mapping