/// <summary> /// Deletes the table specified by tableId from the dataset. If the table contains data, all the data will be deleted. /// Documentation https://developers.google.com/bigquery/v2/reference/tables/delete /// 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 bigquery service.</param> /// <param name="projectId">Project ID of the table to delete</param> /// <param name="datasetId">Dataset ID of the table to delete</param> /// <param name="tableId">Table ID of the table to delete</param> public static void Delete(bigqueryService service, string projectId, string datasetId, string tableId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (projectId == null) { throw new ArgumentNullException(projectId); } if (datasetId == null) { throw new ArgumentNullException(datasetId); } if (tableId == null) { throw new ArgumentNullException(tableId); } // Make the request. return(service.Tables.Delete(projectId, datasetId, tableId).Execute()); } catch (Exception ex) { throw new Exception("Request Tables.Delete failed.", ex); } }
/// <summary> /// Lists all tables in the specified dataset. Requires the READER dataset role. /// Documentation https://developers.google.com/bigquery/v2/reference/tables/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 bigquery service.</param> /// <param name="projectId">Project ID of the tables to list</param> /// <param name="datasetId">Dataset ID of the tables to list</param> /// <param name="optional">Optional paramaters.</param> /// <returns>TableListResponse</returns> public static TableList List(bigqueryService service, string projectId, string datasetId, TablesListOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (projectId == null) { throw new ArgumentNullException(projectId); } if (datasetId == null) { throw new ArgumentNullException(datasetId); } // Building the initial request. var request = service.Tables.List(projectId, datasetId); // Applying optional parameters to the request. request = (TablesResource.ListRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Tables.List failed.", ex); } }
/// <summary> /// Creates a new, empty table in the dataset. /// Documentation https://developers.google.com/bigquery/v2/reference/tables/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 bigquery service.</param> /// <param name="projectId">Project ID of the new table</param> /// <param name="datasetId">Dataset ID of the new table</param> /// <param name="body">A valid bigquery v2 body.</param> /// <returns>TableResponse</returns> public static Table Insert(bigqueryService service, string projectId, string datasetId, Table body) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (projectId == null) { throw new ArgumentNullException(projectId); } if (datasetId == null) { throw new ArgumentNullException(datasetId); } // Make the request. return(service.Tables.Insert(body, projectId, datasetId).Execute()); } catch (Exception ex) { throw new Exception("Request Tables.Insert failed.", ex); } }
/// <summary> /// Returns information about a specific job. Job information is available for a six month period after creation. Requires that you're the person who ran the job, or have the Is Owner project role. /// Documentation https://developers.google.com/bigquery/v2/reference/jobs/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 bigquery service.</param> /// <param name="projectId">[Required] Project ID of the requested job</param> /// <param name="jobId">[Required] Job ID of the requested job</param> /// <returns>JobResponse</returns> public static Job Get(bigqueryService service, string projectId, string jobId) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (projectId == null) { throw new ArgumentNullException(projectId); } if (jobId == null) { throw new ArgumentNullException(jobId); } // Make the request. return(service.Jobs.Get(projectId, jobId).Execute()); } catch (Exception ex) { throw new Exception("Request Jobs.Get failed.", ex); } }
/// <summary> /// Runs a BigQuery SQL query synchronously and returns query results if the query completes within a specified timeout. /// Documentation https://developers.google.com/bigquery/v2/reference/jobs/query /// 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 bigquery service.</param> /// <param name="projectId">Project ID of the project billed for the query</param> /// <param name="body">A valid bigquery v2 body.</param> /// <returns>QueryResponseResponse</returns> public static QueryResponse Query(bigqueryService service, string projectId, QueryRequest body) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (projectId == null) { throw new ArgumentNullException(projectId); } // Make the request. return(service.Jobs.Query(body, projectId).Execute()); } catch (Exception ex) { throw new Exception("Request Jobs.Query failed.", ex); } }
/// <summary> /// Retrieves the results of a query job. /// Documentation https://developers.google.com/bigquery/v2/reference/jobs/getQueryResults /// 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 bigquery service.</param> /// <param name="projectId">[Required] Project ID of the query job</param> /// <param name="jobId">[Required] Job ID of the query job</param> /// <param name="optional">Optional paramaters.</param> /// <returns>GetQueryResultsResponseResponse</returns> public static GetQueryResultsResponse GetQueryResults(bigqueryService service, string projectId, string jobId, JobsGetQueryResultsOptionalParms optional = null) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (projectId == null) { throw new ArgumentNullException(projectId); } if (jobId == null) { throw new ArgumentNullException(jobId); } // Building the initial request. var request = service.Jobs.GetQueryResults(projectId, jobId); // Applying optional parameters to the request. request = (JobsResource.GetQueryResultsRequest)SampleHelpers.ApplyOptionalParms(request, optional); // Requesting data. return(request.Execute()); } catch (Exception ex) { throw new Exception("Request Jobs.GetQueryResults failed.", ex); } }