private IEnumerable <InstanceGroupManager> GetZoneGroups() { InstanceGroupManagersResource.ListRequest request = Service.InstanceGroupManagers.List(Project, Zone); do { InstanceGroupManagerList response = request.Execute(); foreach (InstanceGroupManager manager in response.Items) { yield return(manager); } request.PageToken = response.NextPageToken; } while (!Stopping && request.PageToken != null); }
/// <summary> /// Snaps the InstanceGroupManagers. /// </summary> /// <param name="subscription">The subscription.</param> public static StreamWriter SnapInstanceGroupManagers(Subscription subscription, StreamWriter writer, string ZoneName) { writer.Write("InstanceGroupManagers"); writer.Write(Environment.NewLine); writer.Write("InstanceGroupManager Name", "Zone", "Project", "Created Time", "Status"); writer.Write(Environment.NewLine); string scope = ConfigurationManager.AppSettings["Scope"]; var project = subscription.SubscriptionFriendlyName; ComputeService computeService = new ComputeService(new BaseClientService.Initializer { HttpClientInitializer = GetCredential(ConfigurationManager.AppSettings["AdminUserName"], ConfigurationManager.AppSettings["ServiceAccountKey"], scope), ApplicationName = "Google-ComputeSample/0.1", }); InstanceGroupManagersResource.ListRequest instanceGroupManagersRequest = computeService.InstanceGroupManagers.List(project, ZoneName); ComputeServiceData.InstanceGroupManagerList instanceGroupManagersResponse = instanceGroupManagersRequest.Execute(); do { if (instanceGroupManagersResponse.Items == null) { continue; } foreach (ComputeServiceData.InstanceGroupManager instanceGroupManager in instanceGroupManagersResponse.Items) { writer.Write(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\"", instanceGroupManager.Name, ZoneName, subscription.SubscriptionFriendlyName, instanceGroupManager.CreationTimestamp, "")); writer.Write(Environment.NewLine); } } while (instanceGroupManagersResponse.NextPageToken != null); return(writer); }