/// <summary>Snippet for SetSecurityPolicy</summary> public void SetSecurityPolicy() { // Snippet: SetSecurityPolicy(string, string, SecurityPolicyReference, CallSettings) // Create client BackendServicesClient backendServicesClient = BackendServicesClient.Create(); // Initialize request argument(s) string project = ""; string backendService = ""; SecurityPolicyReference securityPolicyReferenceResource = new SecurityPolicyReference(); // Make the request Operation response = backendServicesClient.SetSecurityPolicy(project, backendService, securityPolicyReferenceResource); // End snippet }
/// <summary>Snippet for SetSecurityPolicyAsync</summary> public async Task SetSecurityPolicyAsync() { // Snippet: SetSecurityPolicyAsync(string, string, SecurityPolicyReference, CallSettings) // Additional: SetSecurityPolicyAsync(string, string, SecurityPolicyReference, CancellationToken) // Create client BackendServicesClient backendServicesClient = await BackendServicesClient.CreateAsync(); // Initialize request argument(s) string project = ""; string backendService = ""; SecurityPolicyReference securityPolicyReferenceResource = new SecurityPolicyReference(); // Make the request Operation response = await backendServicesClient.SetSecurityPolicyAsync(project, backendService, securityPolicyReferenceResource); // End snippet }
/// <summary> /// Sets the security policy for the specified backend service. /// Documentation https://developers.google.com/compute/beta/reference/backendServices/setSecurityPolicy /// 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="backendService">Name of the BackendService resource to which the security policy should be set. The name should conform to RFC1035.</param> /// <param name="body">A valid Compute beta body.</param> /// <param name="optional">Optional paramaters.</param> /// <returns>OperationResponse</returns> public static Operation SetSecurityPolicy(ComputeService service, string project, string backendService, SecurityPolicyReference body, BackendServicesSetSecurityPolicyOptionalParms 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 (backendService == null) { throw new ArgumentNullException(backendService); } // Building the initial request. var request = service.BackendServices.SetSecurityPolicy(body, project, backendService); // Applying optional parameters to the request. request = (BackendServicesResource.SetSecurityPolicyRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request BackendServices.SetSecurityPolicy failed.", ex); } }