Esempio n. 1
0
        /// <summary>
        /// Snaps the BackendServices.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        public static StreamWriter SnapBackendServices(Subscription subscription, StreamWriter writer)
        {
            writer.Write("BackendServices");
            writer.Write(Environment.NewLine);
            writer.Write("BackendServices Name", "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",
            });

            BackendServicesResource.ListRequest   backendServiceRequest = computeService.BackendServices.List(project);
            ComputeServiceData.BackendServiceList backendServiceRequestResponse;
            do
            {
                backendServiceRequestResponse = backendServiceRequest.Execute();
                if (backendServiceRequestResponse.Items == null)
                {
                    continue;
                }

                foreach (ComputeServiceData.BackendService backendService in backendServiceRequestResponse.Items)
                {
                    writer.Write(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\"", backendService.Name, subscription.SubscriptionFriendlyName, backendService.CreationTimestamp, ""));
                    writer.Write(Environment.NewLine);
                }
            } while (backendServiceRequestResponse.NextPageToken != null);

            return(writer);
        }
 private IEnumerable <BackendService> GetAllProjectBackendServices(string project)
 {
     BackendServicesResource.ListRequest request = Service.BackendServices.List(project);
     do
     {
         BackendServiceList response = request.Execute();
         if (response.Items != null)
         {
             foreach (BackendService backendService in response.Items)
             {
                 yield return(backendService);
             }
         }
         request.PageToken = response.NextPageToken;
     } while (!Stopping && request.PageToken != null);
 }