protected override void ProcessRecord() { string project; string name; if (ParameterSetName == ParameterSetNames.ByName) { project = Project; name = Name; } else if (ParameterSetName == ParameterSetNames.ByObject) { project = GetProjectNameFromUri(Object.SelfLink); name = Object.Name; } else { throw UnknownParameterSetException; } DeprecationStatus body = new DeprecationStatus { Replacement = GetReplacementUrl(), State = State.ToString() }; Operation operation = Service.Images.Deprecate(body, project, name).Execute(); AddGlobalOperation(project, operation, () => { WriteObject(Service.Images.Get(project, name).Execute()); }); }
/// <summary>Snippet for Deprecate</summary> public void Deprecate() { // Snippet: Deprecate(string, string, DeprecationStatus, CallSettings) // Create client ImagesClient imagesClient = ImagesClient.Create(); // Initialize request argument(s) string project = ""; string image = ""; DeprecationStatus deprecationStatusResource = new DeprecationStatus(); // Make the request Operation response = imagesClient.Deprecate(project, image, deprecationStatusResource); // End snippet }
/// <summary>Snippet for DeprecateAsync</summary> public async Task DeprecateAsync() { // Snippet: DeprecateAsync(string, string, DeprecationStatus, CallSettings) // Additional: DeprecateAsync(string, string, DeprecationStatus, CancellationToken) // Create client ImagesClient imagesClient = await ImagesClient.CreateAsync(); // Initialize request argument(s) string project = ""; string image = ""; DeprecationStatus deprecationStatusResource = new DeprecationStatus(); // Make the request Operation response = await imagesClient.DeprecateAsync(project, image, deprecationStatusResource); // End snippet }
/// <summary> /// Sets the deprecation status of an image.If an empty request body is given, clears the deprecation status instead. /// Documentation https://developers.google.com/compute/beta/reference/images/deprecate /// 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="image">Image name.</param> /// <param name="body">A valid Compute beta body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>OperationResponse</returns> public static Operation Deprecate(ComputeService service, string project, string image, DeprecationStatus body, ImagesDeprecateOptionalParms 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 (image == null) { throw new ArgumentNullException(image); } // Building the initial request. var request = service.Images.Deprecate(body, project, image); // Applying optional parameters to the request. request = (ImagesResource.DeprecateRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Images.Deprecate failed.", ex); } }
/// Documentation https://developers.google.com/compute/beta/reference/images/deprecate /// 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="image">Image name.</param> /// <param name="body">A valid compute beta body.</param> /// <returns>OperationResponse</returns> public static Operation Deprecate(computeService service, string project, string image, DeprecationStatus 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 (image == null) { throw new ArgumentNullException(image); } // Make the request. return(service.Images.Deprecate(body, project, image).Execute()); } catch (Exception ex) { throw new Exception("Request Images.Deprecate failed.", ex); } }