def CreateRecordSetFromArgs(args): """Creates and returns a record-set from the given args. Args: args: The arguments to use to create the record-set. Raises: ToolException: If given record-set type is not supported Returns: ResourceRecordSet, the record-set created from the given args. """ rd_type = rdatatype.from_text(args.type) if rd_type not in import_util.RDATA_TRANSLATIONS: raise exceptions.ToolException( 'unsupported record-set type [{0}]'.format(args.type)) record_set = messages.ResourceRecordSet() # Need to assign kind to default value for useful equals comparisons. record_set.kind = record_set.kind record_set.name = util.AppendTrailingDot(args.name) record_set.ttl = args.ttl record_set.type = args.type record_set.rrdatas = args.data if rd_type is rdatatype.TXT or rd_type is rdatatype.SPF: record_set.rrdatas = [import_util.QuotedText(datum) for datum in args.data] return record_set
def Run(self, args): dns = self.context['dns_client'] messages = self.context['dns_messages'] resources = self.context['dns_resources'] zone_ref = resources.Parse(args.dns_zone, collection='dns.managedZones') zone = messages.ManagedZone(name=zone_ref.managedZone, dnsName=util.AppendTrailingDot( args.dns_name), description=args.description) result = dns.managedZones.Create( messages.DnsManagedZonesCreateRequest(managedZone=zone, project=zone_ref.project)) log.CreatedResource(zone_ref) return result
def Run(self, args): dns_client = self.context['dns_client'] dns_messages = self.context['dns_messages'] project_id = properties.VALUES.core.project.Get(required=True) if args.type and not args.name: raise exceptions.ToolException( '--name should also be provided when --type is used') return apitools.YieldFromList( dns_client.resourceRecordSets, dns_messages.DnsResourceRecordSetsListRequest( project=project_id, managedZone=args.zone, name=util.AppendTrailingDot(args.name), type=args.type), limit=args.limit, field='rrsets')