/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { ListHostedZonesByNameResponse response = new ListHostedZonesByNameResponse(); UnmarshallResult(context, response); return(response); }
public async Task <string> GetHostedZoneIdByName(string hostedZoneName) { using (AmazonRoute53Client route53Client = GetAmazonRoute53Client()) { ListHostedZonesByNameResponse zones = await route53Client.ListHostedZonesByNameAsync(new ListHostedZonesByNameRequest() { DNSName = hostedZoneName }); HostedZone matchingZone = zones?.HostedZones.FirstOrDefault(zone => zone.Name == hostedZoneName); return(matchingZone?.Id); } }
private async static Task <string> GetHostedZoneIdByName(string hostedZoneName) { AmazonRoute53Config config = new AmazonRoute53Config() { RegionEndpoint = RegionEndpoint.GetBySystemName(Settings.AWSRegion) // TODO: inject }; using (AmazonRoute53Client route53Client = new AmazonRoute53Client(Settings.AWSAccessKeyId, Settings.AWSAccessKeySecret, config)) { ListHostedZonesByNameResponse zones = await route53Client.ListHostedZonesByNameAsync(new ListHostedZonesByNameRequest() { DNSName = hostedZoneName }); HostedZone matchingZone = zones?.HostedZones.FirstOrDefault(zone => zone.Name == hostedZoneName); return(matchingZone?.Id); } }
private static void UnmarshallResult(XmlUnmarshallerContext context, ListHostedZonesByNameResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 1; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("HostedZones/HostedZone", targetDepth)) { var unmarshaller = HostedZoneUnmarshaller.Instance; response.HostedZones.Add(unmarshaller.Unmarshall(context)); continue; } if (context.TestExpression("DNSName", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DNSName = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("HostedZoneId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.HostedZoneId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("IsTruncated", targetDepth)) { var unmarshaller = BoolUnmarshaller.Instance; response.IsTruncated = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextDNSName", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextDNSName = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("NextHostedZoneId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextHostedZoneId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("MaxItems", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.MaxItems = unmarshaller.Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }