Exemple #1
0
        /// <summary>
        /// Snaps the Addresses.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        public static StreamWriter SnapAddresses(Subscription subscription, StreamWriter writer, string RegionName)
        {
            writer.Write("Addresses");
            writer.Write(Environment.NewLine);
            writer.Write("Addresse Name", "Region", "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",
            });

            AddressesResource.ListRequest  addressRequest  = computeService.Addresses.List(project, RegionName);
            ComputeServiceData.AddressList addressResponse = addressRequest.Execute();

            do
            {
                if (addressResponse.Items == null)
                {
                    continue;
                }

                foreach (var address in addressResponse.Items)
                {
                    writer.Write(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\"", address.Name, RegionName, subscription.SubscriptionFriendlyName, address.CreationTimestamp, ""));
                    writer.Write(Environment.NewLine);
                }
            } while (addressResponse.NextPageToken != null);

            return(writer);
        }
Exemple #2
0
 private IEnumerable <Address> GetRegionAddresses()
 {
     AddressesResource.ListRequest request = Service.Addresses.List(Project, Region);
     do
     {
         AddressList response = request.Execute();
         if (response.Items != null)
         {
             foreach (Address address in response.Items)
             {
                 yield return(address);
             }
         }
         request.PageToken = response.NextPageToken;
     } while (!Stopping && request.PageToken != null);
 }