/// <summary>
        /// Exports data from a Cloud SQL instance to a Google Cloud Storage bucket as a MySQL dump file.
        /// Documentation https://developers.google.com/sqladmin/v1beta4/reference/instances/export
        /// 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 that contains the instance to be exported.</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>OperationResponse</returns>
        public static Operation Export(SqladminService service, string project, string instance, InstancesExportRequest 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.Instances.Export(body, project, instance).Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Instances.Export failed.", ex);
            }
        }
 protected override void ProcessRecord()
 {
     InstancesExportRequest body = new InstancesExportRequest
     {
         ExportContext = new ExportContext
         {
             Kind = "sql#exportContext",
             Databases = Database,
             Uri = CloudStorageDestination,
             FileType = ParameterSetName.ToString()
         }
     };
     switch (ParameterSetName)
     {
         case ParameterSetNames.Sql:
             body.ExportContext.SqlExportOptions = new ExportContext.SqlExportOptionsData
             {
                 SchemaOnly = SchemaOnly,
                 Tables = Table
             };
             break;
         case ParameterSetNames.Csv:
             body.ExportContext.CsvExportOptions = new ExportContext.CsvExportOptionsData
             {
                 SelectQuery = SelectQuery
             };
             break;
         default:
             throw UnknownParameterSetException;
     }
     InstancesResource.ExportRequest request = Service.Instances.Export(body, Project, Instance);
     WriteVerbose($"Exporting to '{CloudStorageDestination}' from Instance '{Instance}'.");
     Operation result = request.Execute();
     result = WaitForSqlOperation(result);
     if (result.Error != null)
     {
         foreach (OperationError error in result.Error.Errors)
         {
             throw new GoogleApiException("Google Cloud SQL API", error.Message + error.Code);
         }
     }
 }