Ejemplo n.º 1
0
        /// <summary>
        /// Returns permissions that a caller has on the specified resource.
        /// Documentation https://developers.google.com/deploymentmanager/v2/reference/deployments/testIamPermissions
        /// 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 DeploymentManager service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="resource">Name of the resource for this request.</param>
        /// <param name="body">A valid DeploymentManager v2 body.</param>
        /// <returns>TestPermissionsResponseResponse</returns>
        public static TestPermissionsResponse TestIamPermissions(DeploymentManagerService service, string project, string resource, TestPermissionsRequest 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 (resource == null)
                {
                    throw new ArgumentNullException(resource);
                }

                // Make the request.
                return(service.Deployments.TestIamPermissions(body, project, resource).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Deployments.TestIamPermissions failed.", ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Cancels and removes the preview currently associated with the deployment.
        /// Documentation https://developers.google.com/deploymentmanager/v2/reference/deployments/cancelPreview
        /// 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 DeploymentManager service.</param>
        /// <param name="project">The project ID for this request.</param>
        /// <param name="deployment">The name of the deployment for this request.</param>
        /// <param name="body">A valid DeploymentManager v2 body.</param>
        /// <returns>OperationResponse</returns>
        public static Operation CancelPreview(DeploymentManagerService service, string project, string deployment, DeploymentsCancelPreviewRequest 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 (deployment == null)
                {
                    throw new ArgumentNullException(deployment);
                }

                // Make the request.
                return(service.Deployments.CancelPreview(body, project, deployment).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Deployments.CancelPreview failed.", ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Lists all deployments for a given project.
        /// Documentation https://developers.google.com/deploymentmanager/v2/reference/deployments/list
        /// 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 DeploymentManager service.</param>
        /// <param name="project">The project ID for this request.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>DeploymentsListResponseResponse</returns>
        public static DeploymentsListResponse List(DeploymentManagerService service, string project, DeploymentsListOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }

                // Building the initial request.
                var request = service.Deployments.List(project);

                // Applying optional parameters to the request.
                request = (DeploymentsResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Deployments.List failed.", ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the access control policy for a resource. May be empty if no such policy or resource exists.
        /// Documentation https://developers.google.com/deploymentmanager/v2/reference/deployments/getIamPolicy
        /// 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 DeploymentManager service.</param>
        /// <param name="project">Project ID for this request.</param>
        /// <param name="resource">Name of the resource for this request.</param>
        /// <returns>PolicyResponse</returns>
        public static Policy GetIamPolicy(DeploymentManagerService service, string project, string resource)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (resource == null)
                {
                    throw new ArgumentNullException(resource);
                }

                // Make the request.
                return(service.Deployments.GetIamPolicy(project, resource).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Deployments.GetIamPolicy failed.", ex);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets information about a specific deployment.
        /// Documentation https://developers.google.com/deploymentmanager/v2/reference/deployments/get
        /// 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 DeploymentManager service.</param>
        /// <param name="project">The project ID for this request.</param>
        /// <param name="deployment">The name of the deployment for this request.</param>
        /// <returns>DeploymentResponse</returns>
        public static Deployment Get(DeploymentManagerService service, string project, string deployment)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (project == null)
                {
                    throw new ArgumentNullException(project);
                }
                if (deployment == null)
                {
                    throw new ArgumentNullException(deployment);
                }

                // Make the request.
                return(service.Deployments.Get(project, deployment).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Deployments.Get failed.", ex);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Snaps the Deployments.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        public static StreamWriter SnapDeployments(Subscription subscription, StreamWriter writer)
        {
            writer.Write("Deployments");
            writer.Write(Environment.NewLine);
            writer.Write("Deployment Name", "Project", "Created Time", "Status");
            writer.Write(Environment.NewLine);

            string scope   = ConfigurationManager.AppSettings["Scope"];
            var    project = subscription.SubscriptionFriendlyName;
            DeploymentManagerService deploymentManagerService = new DeploymentManagerService(new BaseClientService.Initializer
            {
                HttpClientInitializer = GetCredential(ConfigurationManager.AppSettings["AdminUserName"], ConfigurationManager.AppSettings["ServiceAccountKey"], scope),
                ApplicationName       = "Google-ComputeSample/0.1",
            });

            DeploymentsResource.ListRequest deploymentRequest = deploymentManagerService.Deployments.List(project);
            DeploymentManagerData.DeploymentsListResponse deploymentResponse = deploymentRequest.Execute();
            do
            {
                if (deploymentResponse.Deployments == null)
                {
                    continue;
                }

                foreach (var deployment in deploymentResponse.Deployments)
                {
                    writer.Write(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\"", deployment.Name, subscription.SubscriptionFriendlyName, deployment.InsertTime, ""));
                    writer.Write(Environment.NewLine);
                }
            } while (deploymentResponse.NextPageToken != null);

            return(writer);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Updates a deployment and all of the resources described by the deployment manifest.
        /// Documentation https://developers.google.com/deploymentmanager/v2/reference/deployments/update
        /// 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 DeploymentManager service.</param>
        /// <param name="project">The project ID for this request.</param>
        /// <param name="deployment">The name of the deployment for this request.</param>
        /// <param name="body">A valid DeploymentManager v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>        /// <returns>OperationResponse</returns>
        public static Operation Update(DeploymentManagerService service, string project, string deployment, Deployment body, DeploymentsUpdateOptionalParms 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 (deployment == null)
                {
                    throw new ArgumentNullException(deployment);
                }

                // Building the initial request.
                var request = service.Deployments.Update(body, project, deployment);

                // Applying optional parameters to the request.
                request = (DeploymentsResource.UpdateRequest)SampleHelpers.ApplyOptionalParms(request, optional);

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