public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonIdentityManagementServiceConfig config = new AmazonIdentityManagementServiceConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonIdentityManagementServiceClient client = new AmazonIdentityManagementServiceClient(creds, config); ListInstanceProfilesResponse resp = new ListInstanceProfilesResponse(); do { ListInstanceProfilesRequest req = new ListInstanceProfilesRequest { Marker = resp.Marker , MaxItems = maxItems }; resp = client.ListInstanceProfiles(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.InstanceProfiles) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.Marker)); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { ListInstanceProfilesResponse response = new ListInstanceProfilesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("instanceProfiles", targetDepth)) { var unmarshaller = new ListUnmarshaller <InstanceProfile, InstanceProfileUnmarshaller>(InstanceProfileUnmarshaller.Instance); response.InstanceProfiles = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("nextToken", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.NextToken = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { ListInstanceProfilesResponse response = new ListInstanceProfilesResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.IsStartElement) { if (context.TestExpression("ListInstanceProfilesResult", 2)) { UnmarshallResult(context, response); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context); } } } return(response); }
public async Task <InstanceProfile[]> ListInstanceProfilesAsync(string pathPrefx = null, CancellationToken cancellationToken = default(CancellationToken)) { ListInstanceProfilesResponse response = null; var results = new List <InstanceProfile>(); while ((response = await _IAMClient.ListInstanceProfilesAsync(new ListInstanceProfilesRequest() { MaxItems = 100, Marker = response?.Marker, PathPrefix = pathPrefx, }, cancellationToken).EnsureSuccessAsync()) != null) { if (!response.InstanceProfiles.IsNullOrEmpty()) { results.AddRange(response.InstanceProfiles); } if (!response.IsTruncated) { break; } await Task.Delay(100); } return(results.ToArray()); }
private static void UnmarshallResult(XmlUnmarshallerContext context, ListInstanceProfilesResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; if (context.IsStartOfDocument) { targetDepth += 2; } while (context.Read()) { if (context.IsStartElement || context.IsAttribute) { if (context.TestExpression("InstanceProfiles/member", targetDepth)) { response.InstanceProfiles.Add(InstanceProfileUnmarshaller.GetInstance().Unmarshall(context)); continue; } if (context.TestExpression("IsTruncated", targetDepth)) { response.IsTruncated = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Marker", targetDepth)) { response.Marker = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } } else if (context.IsEndElement && context.CurrentDepth < originalDepth) { return; } } return; }
private static void UnmarshallResult(XmlUnmarshallerContext context, ListInstanceProfilesResponse 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("InstanceProfiles/member", targetDepth)) { var unmarshaller = InstanceProfileUnmarshaller.Instance; var item = unmarshaller.Unmarshall(context); response.InstanceProfiles.Add(item); continue; } 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; } } } return; }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { ListInstanceProfilesResponse response = new ListInstanceProfilesResponse(); while (context.Read()) { if (context.IsStartElement) { if (context.TestExpression("ListInstanceProfilesResult", 2)) { response.ListInstanceProfilesResult = ListInstanceProfilesResultUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("ResponseMetadata", 2)) { response.ResponseMetadata = ResponseMetadataUnmarshaller.GetInstance().Unmarshall(context); } } } return(response); }
public static async Task <IList <InstanceProfile> > FindExistingInstanceProfilesAsync(IAmazonIdentityManagementService iamClient, int maxRoles) { var profiles = new List <InstanceProfile>(); ListInstanceProfilesRequest request = new ListInstanceProfilesRequest(); ListInstanceProfilesResponse response = null; do { if (response != null) { request.Marker = response.Marker; } response = await iamClient.ListInstanceProfilesAsync(request).ConfigureAwait(false); foreach (var profile in response.InstanceProfiles) { profiles.Add(profile); } } while (response.IsTruncated && profiles.Count < maxRoles); return(profiles); }