// awsGetZonesHandler returns the list of Route53 Hosted Zones.
awsGetZonesHandler returns the list of Route53 Hosted Zones.
// awsGetZonesHandler returns the list of Route53 Hosted Zones .
func awsGetZonesHandler(w http.ResponseWriter, req *http.Request, _ *Context) error {
	addHostedZones := func(allZones *[]*route53.HostedZone, marker *string) error {
		awsSession, err := awsSessionFromRequest(req)
		if err != nil {
			return err
		}
		route53svc := route53.New(awsSession)
		requestInput := route53.ListHostedZonesInput{}
		if *marker != "" {
			requestInput = route53.ListHostedZonesInput{Marker: marker}
		}
		resp, err := route53svc.ListHostedZones(&requestInput)
		if err != nil {
			return err
		}
		*allZones = append(*allZones, resp.HostedZones...)
		if *resp.IsTruncated == true {
			*marker = *resp.NextMarker
		} else {
			*marker = "complete"
		}
		return nil
	}
	var allZones []*route53.HostedZone
	var marker string
	for marker != "complete" {
		err := addHostedZones(&allZones, &marker)
		if err != nil {
			return fromAWSErr(err)
		}
	}
	response := []labelValue{}
	for _, key := range allZones {
		label := strings.TrimSuffix(aws.StringValue(key.Name), ".")
		if aws.BoolValue(key.Config.PrivateZone) {
			label = fmt.Sprintf("%s (private)", label)
		}
		response = append(response, labelValue{label, aws.StringValue(key.Id)})
	}
	sort.Slice(response, func(i, j int) bool {
		return response[i].Label >= response[j].Label
	})
	return writeJSONResponse(w, req, http.StatusOK, response)
}
func awsGetZonesHandler ( w http . ResponseWriter , req * http . Request , _ * Context ) error { addHostedZones := func ( allZones * [ ] * route53 . HostedZone , marker * string ) error { awsSession , err := awsSessionFromRequest ( req ) if err != nil { return err } route53svc := route53 . New ( awsSession ) requestInput := route53 . ListHostedZonesInput { } if * marker != " " { requestInput = route53 . ListHostedZonesInput { Marker : marker } } resp , err := route53svc . ListHostedZones ( & requestInput ) if err != nil { return err } * allZones = append ( * allZones , resp . HostedZones ... ) if * resp . IsTruncated == true { * marker = * resp . NextMarker } else { * marker = " " } return nil } var allZones [ ] * route53 . HostedZone var marker string for marker != " " { err := addHostedZones ( & allZones , & marker ) if err != nil { return fromAWSErr ( err ) } } response := [ ] labelValue { } for _ , key := range allZones { label := strings . TrimSuffix ( aws . StringValue ( key . Name ) , " " ) if aws . BoolValue ( key . Config . PrivateZone ) { label = fmt . Sprintf ( " " , label ) } response = append ( response , labelValue { label , aws . StringValue ( key . Id ) } ) } sort . Slice ( response , func ( i , j int ) bool { return response [ i ] . Label >= response [ j ] . Label } ) return writeJSONResponse ( w , req , http . StatusOK , response ) }
awsGetZonesHandler returns the list of Route53 Hosted Zones.
awsGetZonesHandler returns the list of Route53 Hosted Zones .
// Strip trailing dot off domain names & add "(private)" to private zones