Esempio n. 1
0
        private void AddInstanceToPool(string project, string region, string name)
        {
            TargetPoolsAddInstanceRequest addBody = new TargetPoolsAddInstanceRequest
            {
                Instances = AddInstance.Select(i => new InstanceReference {
                    Instance = i
                }).ToList()
            };

            AddRegionOperation(project, region,
                               Service.TargetPools.AddInstance(addBody, project, region, name).Execute(),
                               () => WriteObject(Service.TargetPools.Get(project, region, name).Execute()));
        }
 /// <summary>Snippet for AddInstance</summary>
 public void AddInstance()
 {
     // Snippet: AddInstance(string, string, string, TargetPoolsAddInstanceRequest, CallSettings)
     // Create client
     TargetPoolsClient targetPoolsClient = TargetPoolsClient.Create();
     // Initialize request argument(s)
     string project    = "";
     string region     = "";
     string targetPool = "";
     TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource = new TargetPoolsAddInstanceRequest();
     // Make the request
     Operation response = targetPoolsClient.AddInstance(project, region, targetPool, targetPoolsAddInstanceRequestResource);
     // End snippet
 }
        /// <summary>Snippet for AddInstanceAsync</summary>
        public async Task AddInstanceAsync()
        {
            // Snippet: AddInstanceAsync(string, string, string, TargetPoolsAddInstanceRequest, CallSettings)
            // Additional: AddInstanceAsync(string, string, string, TargetPoolsAddInstanceRequest, CancellationToken)
            // Create client
            TargetPoolsClient targetPoolsClient = await TargetPoolsClient.CreateAsync();

            // Initialize request argument(s)
            string project    = "";
            string region     = "";
            string targetPool = "";
            TargetPoolsAddInstanceRequest targetPoolsAddInstanceRequestResource = new TargetPoolsAddInstanceRequest();
            // Make the request
            Operation response = await targetPoolsClient.AddInstanceAsync(project, region, targetPool, targetPoolsAddInstanceRequestResource);

            // End snippet
        }
        /// <summary>
        /// Adds an instance to a target pool.
        /// Documentation https://developers.google.com/compute/beta/reference/targetPools/addInstance
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="region">Name of the region scoping this request.</param>
        /// <param name="targetPool">Name of the TargetPool resource to add instances to.</param>
        /// <param name="body">A valid compute beta body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation AddInstance(computeService service, string project, string region, string targetPool, TargetPoolsAddInstanceRequest body)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (region == null)
                {
                    throw new ArgumentNullException(region);
                }
                if (targetPool == null)
                {
                    throw new ArgumentNullException(targetPool);
                }

                // Make the request.
                return(service.TargetPools.AddInstance(body, project, region, targetPool).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetPools.AddInstance failed.", ex);
            }
        }
 private void AddInstanceToPool(string project, string region, string name)
 {
     TargetPoolsAddInstanceRequest addBody = new TargetPoolsAddInstanceRequest
     {
         Instances = AddInstance.Select(i => new InstanceReference { Instance = i }).ToList()
     };
     AddRegionOperation(project, region,
         Service.TargetPools.AddInstance(addBody, project, region, name).Execute(),
         () => WriteObject(Service.TargetPools.Get(project, region, name).Execute()));
 }
Esempio n. 6
0
        /// <summary>
        /// Adds an instance to a target pool.
        /// Documentation https://developers.google.com/compute/alpha/reference/targetPools/addInstance
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Compute service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="region">Name of the region scoping this request.</param>
        /// <param name="targetPool">Name of the TargetPool resource to add instances to.</param>
        /// <param name="body">A valid Compute alpha body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>OperationResponse</returns>
        public static Operation AddInstance(ComputeService service, string project, string region, string targetPool, TargetPoolsAddInstanceRequest body, TargetPoolsAddInstanceOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (region == null)
                {
                    throw new ArgumentNullException(region);
                }
                if (targetPool == null)
                {
                    throw new ArgumentNullException(targetPool);
                }

                // Building the initial request.
                var request = service.TargetPools.AddInstance(body, project, region, targetPool);

                // Applying optional parameters to the request.
                request = (TargetPoolsResource.AddInstanceRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request TargetPools.AddInstance failed.", ex);
            }
        }