/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { ListPolicyVersionsResponse response = new ListPolicyVersionsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("ListPolicyVersionsResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
public async Task <PolicyVersion[]> ListPolicyVersionsAsync(string arn, CancellationToken cancellationToken = default(CancellationToken)) { ListPolicyVersionsResponse response = null; var results = new List <PolicyVersion>(); while ((response = await _IAMClient.ListPolicyVersionsAsync(new ListPolicyVersionsRequest() { Marker = response?.Marker, MaxItems = 1000, PolicyArn = arn }, cancellationToken).EnsureSuccessAsync()) != null) { if (!response.Versions.IsNullOrEmpty()) { results.AddRange(response.Versions); } if (!response.IsTruncated) { break; } await Task.Delay(100); } return(results.ToArray()); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListPolicyVersionsResponse response = new ListPolicyVersionsResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("policyVersions", targetDepth)) { var unmarshaller = new ListUnmarshaller <PolicyVersion, PolicyVersionUnmarshaller>(PolicyVersionUnmarshaller.Instance); response.PolicyVersions = unmarshaller.Unmarshall(context); continue; } } return(response); }
private static void UnmarshallResult(XmlUnmarshallerContext context, ListPolicyVersionsResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.ReadAtDepth(originalDepth)) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("IsTruncated", targetDepth)) { var unmarshaller = BoolUnmarshaller.Instance; response.IsTruncated = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Marker", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Marker = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Versions/member", targetDepth)) { var unmarshaller = PolicyVersionUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.Versions.Add(item); continue; } } } return; }
public static ListPolicyVersionsResponse Unmarshall(UnmarshallerContext context) { ListPolicyVersionsResponse listPolicyVersionsResponse = new ListPolicyVersionsResponse(); listPolicyVersionsResponse.HttpResponse = context.HttpResponse; listPolicyVersionsResponse.RequestId = context.StringValue("ListPolicyVersions.RequestId"); List <ListPolicyVersionsResponse.ListPolicyVersions_PolicyVersion> listPolicyVersionsResponse_policyVersions = new List <ListPolicyVersionsResponse.ListPolicyVersions_PolicyVersion>(); for (int i = 0; i < context.Length("ListPolicyVersions.PolicyVersions.Length"); i++) { ListPolicyVersionsResponse.ListPolicyVersions_PolicyVersion policyVersion = new ListPolicyVersionsResponse.ListPolicyVersions_PolicyVersion(); policyVersion.VersionId = context.StringValue("ListPolicyVersions.PolicyVersions[" + i + "].VersionId"); policyVersion.IsDefaultVersion = context.BooleanValue("ListPolicyVersions.PolicyVersions[" + i + "].IsDefaultVersion"); policyVersion.PolicyDocument = context.StringValue("ListPolicyVersions.PolicyVersions[" + i + "].PolicyDocument"); policyVersion.CreateDate = context.StringValue("ListPolicyVersions.PolicyVersions[" + i + "].CreateDate"); listPolicyVersionsResponse_policyVersions.Add(policyVersion); } listPolicyVersionsResponse.PolicyVersions = listPolicyVersionsResponse_policyVersions; return(listPolicyVersionsResponse); }