protected override void ProcessRecord() { string project; string instance; switch (ParameterSetName) { case ParameterSetNames.ByName: instance = Instance; project = Project; break; case ParameterSetNames.ByInstance: instance = InstanceObject.Name; project = InstanceObject.Project; break; default: throw UnknownParameterSetException; } SslCertsInsertRequest RequestBody = new SslCertsInsertRequest { CommonName = CommonName }; SslCertsResource.InsertRequest request = Service.SslCerts.Insert(RequestBody, project, instance); WriteVerbose($"Adding the SSL Certificate '{CommonName}' to the Instance {instance}."); SslCertsInsertResponse result = request.Execute(); WriteObject(result.ClientCert); }
/// <summary> /// Creates an SSL certificate and returns it along with the private key and server certificate authority. The new certificate will not be usable until the instance is restarted. /// Documentation https://developers.google.com/sqladmin/v1beta4/reference/sslCerts/insert /// 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 SQLAdmin service.</param> /// <param name="project">Project ID of the project to which the newly created Cloud SQL instances should belong.</param> /// <param name="instance">Cloud SQL instance ID. This does not include the project ID.</param> /// <param name="body">A valid SQLAdmin v1beta4 body.</param> /// <returns>SslCertsInsertResponseResponse</returns> public static SslCertsInsertResponse Insert(SQLAdminService service, string project, string instance, SslCertsInsertRequest 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 (instance == null) { throw new ArgumentNullException(instance); } // Make the request. return(service.SslCerts.Insert(body, project, instance).Execute()); } catch (Exception ex) { throw new Exception("Request SslCerts.Insert failed.", ex); } }