示例#1
0
 /// <summary>
 /// Creates the specified dataset.
 /// </summary>
 /// <param name="datasetReference">A fully-qualified identifier for the dataset. Must not be null.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The created dataset.</returns>
 public virtual BigQueryDataset CreateDataset(DatasetReference datasetReference, CreateDatasetOptions options = null)
 {
     throw new NotImplementedException();
 }
        /// <inheritdoc />
        public override BigQueryDataset CreateDataset(DatasetReference datasetReference, CreateDatasetOptions options = null)
        {
            GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
            var dataset = new Dataset {
                DatasetReference = datasetReference
            };
            var request = Service.Datasets.Insert(dataset, datasetReference.ProjectId);

            options?.ModifyRequest(dataset, request);
            return(new BigQueryDataset(this, request.Execute()));
        }
 /// <inheritdoc />
 public override BigQueryDataset GetOrCreateDataset(DatasetReference datasetReference, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null)
 {
     GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
     try
     {
         return(GetDataset(datasetReference, getOptions));
     }
     catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
     {
         return(CreateDataset(datasetReference, createOptions));
     }
 }
 /// <inheritdoc />
 public override async Task <BigQueryDataset> GetOrCreateDatasetAsync(DatasetReference datasetReference, Dataset resource = null, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null, CancellationToken cancellationToken = default)
 {
     GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
     GaxPreconditions.CheckArgument(
         resource?.DatasetReference == null || datasetReference.ReferencesSameAs(resource.DatasetReference),
         nameof(resource.DatasetReference),
         $"If {nameof(resource.DatasetReference)} is specified, it must be the same as {nameof(datasetReference)}");
     try
     {
         return(await GetDatasetAsync(datasetReference, getOptions, cancellationToken).ConfigureAwait(false));
     }
     catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
     {
         return(await CreateDatasetAsync(datasetReference, resource, createOptions, cancellationToken).ConfigureAwait(false));;
     }
 }
 /// <inheritdoc />
 public override async Task <BigQueryDataset> GetOrCreateDatasetAsync(DatasetReference datasetReference, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
     try
     {
         return(await GetDatasetAsync(datasetReference, getOptions, cancellationToken).ConfigureAwait(false));
     }
     catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
     {
         return(await CreateDatasetAsync(datasetReference, createOptions, cancellationToken).ConfigureAwait(false));;
     }
 }
示例#6
0
 /// <summary>
 /// Asynchronously creates a dataset with the specified ID in this client's project.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="CreateDatasetAsync(DatasetReference,CreateDatasetOptions,CancellationToken)"/>.
 /// </summary>
 /// <param name="datasetId">The new dataset ID. Must not be null.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is
 /// the created dataset.</returns>
 public virtual Task <BigQueryDataset> CreateDatasetAsync(string datasetId,
                                                          CreateDatasetOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 CreateDatasetAsync(GetDatasetReference(datasetId), options, cancellationToken);
示例#7
0
 /// <summary>
 /// Asynchronously attempts to fetch the specified dataset, creating it if it doesn't exist.
 /// </summary>
 /// <param name="datasetReference">A fully-qualified identifier for the dataset. Must not be null.</param>
 /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is
 /// the existing or new dataset.</returns>
 public virtual Task <BigQueryDataset> GetOrCreateDatasetAsync(DatasetReference datasetReference, GetDatasetOptions getOptions = null,
                                                               CreateDatasetOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     throw new NotImplementedException();
 }
示例#8
0
 /// <summary>
 /// Asynchronously creates the specified dataset.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="CreateDatasetAsync(DatasetReference, Dataset, CreateDatasetOptions, CancellationToken)"/>.
 /// </summary>
 /// <remarks>
 /// If <paramref name="resource" /><see cref="Dataset.DatasetReference" /> is specified, then it must be the same as the <see cref="DatasetReference" /> obtained from the other parameters.
 /// </remarks>
 /// <param name="projectId">The project ID. Must not be null.</param>
 /// <param name="datasetId">The dataset ID. Must not be null.</param>
 /// <param name="resource">The dataset resource representation to use for the creation. May be null in which case default values will be used.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is
 /// the created dataset.</returns>
 public virtual Task <BigQueryDataset> CreateDatasetAsync(string projectId, string datasetId, Dataset resource = null, CreateDatasetOptions options = null, CancellationToken cancellationToken = default) =>
 CreateDatasetAsync(GetDatasetReference(projectId, datasetId), resource, options, cancellationToken);
示例#9
0
 /// <summary>
 /// Asynchronously creates the specified dataset.
 /// </summary>
 /// <remarks>
 /// If <paramref name="resource" /><see cref="Dataset.DatasetReference" /> is specified, then it must be the same as the <see cref="DatasetReference" /> obtained from the other parameters.
 /// </remarks>
 /// <param name="datasetReference">A fully-qualified identifier for the dataset. Must not be null.</param>
 /// <param name="resource">The dataset resource representation to use for the creation. May be null in which case default values will be used.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is
 /// the created dataset.</returns>
 public virtual Task <BigQueryDataset> CreateDatasetAsync(DatasetReference datasetReference, Dataset resource = null, CreateDatasetOptions options = null, CancellationToken cancellationToken = default) =>
 throw new NotImplementedException();
        /// <inheritdoc />
        public override async Task <BigQueryDataset> CreateDatasetAsync(DatasetReference datasetReference, CreateDatasetOptions options = null, CancellationToken cancellationToken = default)
        {
            var request = CreateInsertDatasetRequest(datasetReference, options);

            return(new BigQueryDataset(this, await request.ExecuteAsync(cancellationToken).ConfigureAwait(false)));
        }
示例#11
0
 /// <summary>
 /// Creates the specified dataset.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="CreateDataset(DatasetReference, Dataset, CreateDatasetOptions)"/>.
 /// </summary>
 /// <remarks>
 /// If <paramref name="resource" /><see cref="Dataset.DatasetReference" /> is specified, then it must be the same as the <see cref="DatasetReference" /> obtained from the other parameters.
 /// </remarks>
 /// <param name="projectId">The project ID. Must not be null.</param>
 /// <param name="datasetId">The dataset ID. Must not be null.</param>
 /// <param name="resource">The dataset resource representation to use for the creation. May be null in which case default values will be used.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The created dataset.</returns>
 public virtual BigQueryDataset CreateDataset(string projectId, string datasetId, Dataset resource = null, CreateDatasetOptions options = null) =>
 CreateDataset(GetDatasetReference(projectId, datasetId), resource, options);
        /// <inheritdoc />
        public override BigQueryDataset CreateDataset(DatasetReference datasetReference, CreateDatasetOptions options = null)
        {
            var request = CreateInsertDatasetRequest(datasetReference, options);

            return(new BigQueryDataset(this, request.Execute()));
        }
        private InsertRequest CreateInsertDatasetRequest(DatasetReference datasetReference, CreateDatasetOptions options)
        {
            GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
            var dataset = new Dataset {
                DatasetReference = datasetReference, Location = DefaultLocation
            };
            var request = Service.Datasets.Insert(dataset, datasetReference.ProjectId);

            options?.ModifyRequest(dataset, request);
            return(request);
        }
        private InsertRequest CreateInsertDatasetRequest(DatasetReference datasetReference, Dataset resource, CreateDatasetOptions options)
        {
            GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
            GaxPreconditions.CheckArgument(
                resource?.DatasetReference == null || datasetReference.ReferencesSameAs(resource.DatasetReference),
                nameof(resource.DatasetReference),
                $"If {nameof(resource.DatasetReference)} is specified, it must be the same as {nameof(datasetReference)}");

            resource ??= new Dataset();
            resource.DatasetReference ??= datasetReference;
            resource.Location ??= DefaultLocation;

            var request = Service.Datasets.Insert(resource, datasetReference.ProjectId);

            options?.ModifyRequest(request);
            request.PrettyPrint = PrettyPrint;
            return(request);
        }
示例#15
0
 /// <summary>
 /// Attempts to fetch the specified dataset within the given project, creating it if it doesn't exist.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="GetOrCreateDataset(DatasetReference,GetDatasetOptions,CreateDatasetOptions)"/>.
 /// </summary>
 /// <param name="projectId">The project ID. Must not be null.</param>
 /// <param name="datasetId">The dataset ID. Must not be null.</param>
 /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The existing or new dataset.</returns>
 public virtual BigQueryDataset GetOrCreateDataset(string projectId, string datasetId, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null) =>
 GetOrCreateDataset(GetDatasetReference(projectId, datasetId), getOptions, createOptions);
示例#16
0
 /// <summary>
 /// Attempts to fetch the specified dataset within this client's project, creating it if it doesn't exist.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="GetOrCreateDataset(DatasetReference, Dataset, GetDatasetOptions, CreateDatasetOptions)"/>.
 /// </summary>
 /// <remarks>
 /// If <paramref name="resource" /><see cref="Dataset.DatasetReference" /> is specified, then it must be the same as the <see cref="DatasetReference" /> obtained from the other parameters.
 /// </remarks>
 /// <param name="datasetId">The dataset ID. Must not be null.</param>
 /// <param name="resource">The dataset resource representation to use for the creation. May be null in which case default values will be used.</param>
 /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The existing or new dataset.</returns>
 public virtual BigQueryDataset GetOrCreateDataset(string datasetId, Dataset resource = null, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null) =>
 GetOrCreateDataset(GetDatasetReference(datasetId), resource, getOptions, createOptions);
示例#17
0
 /// <summary>
 /// Attempts to fetch the specified dataset, creating it if it doesn't exist.
 /// </summary>
 /// <param name="datasetReference">A fully-qualified identifier for the dataset. Must not be null.</param>
 /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The existing or new dataset.</returns>
 public virtual BigQueryDataset GetOrCreateDataset(DatasetReference datasetReference, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null)
 {
     throw new NotImplementedException();
 }
示例#18
0
 /// <summary>
 /// Asynchronously attempts to fetch the specified dataset within this client's project, creating it if it doesn't exist.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="GetOrCreateDatasetAsync(DatasetReference, Dataset, GetDatasetOptions, CreateDatasetOptions, CancellationToken)"/>.
 /// </summary>
 /// <remarks>
 /// If <paramref name="resource" /><see cref="Dataset.DatasetReference" /> is specified, then it must be the same as the <see cref="DatasetReference" /> obtained from the other parameters.
 /// </remarks>
 /// <param name="datasetId">The dataset ID. Must not be null.</param>
 /// <param name="resource">The dataset resource representation to use for the creation. May be null in which case default values will be used.</param>
 /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is
 /// the existing or new dataset.</returns>
 public virtual Task <BigQueryDataset> GetOrCreateDatasetAsync(string datasetId, Dataset resource = null, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null, CancellationToken cancellationToken = default) =>
 GetOrCreateDatasetAsync(GetDatasetReference(datasetId), resource, getOptions, createOptions, cancellationToken);
示例#19
0
 /// <summary>
 /// Asynchronously attempts to fetch the specified dataset within the given project, creating it if it doesn't exist.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="GetOrCreateDatasetAsync(DatasetReference,GetDatasetOptions,CreateDatasetOptions,CancellationToken)"/>.
 /// </summary>
 /// <param name="projectId">The project ID. Must not be null.</param>
 /// <param name="datasetId">The dataset ID. Must not be null.</param>
 /// <param name="getOptions">The options for the "get" operation. May be null, in which case defaults will be supplied.</param>
 /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
 /// <param name="createOptions">The options for the "create" operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>A task representing the asynchronous operation. When complete, the result is
 /// the existing or new dataset.</returns>
 public virtual Task <BigQueryDataset> GetOrCreateDatasetAsync(string projectId, string datasetId,
                                                               GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null, CancellationToken cancellationToken = default(CancellationToken)) =>
 GetOrCreateDatasetAsync(GetDatasetReference(projectId, datasetId), getOptions, createOptions, cancellationToken);
        /// <inheritdoc />
        public override async Task <BigQueryDataset> CreateDatasetAsync(DatasetReference datasetReference, CreateDatasetOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
            var dataset = new Dataset {
                DatasetReference = datasetReference
            };
            var request = Service.Datasets.Insert(dataset, datasetReference.ProjectId);

            options?.ModifyRequest(dataset, request);
            return(new BigQueryDataset(this, await request.ExecuteAsync(cancellationToken).ConfigureAwait(false)));
        }
示例#21
0
 /// <summary>
 /// Creates a dataset with the specified ID in this client's project.
 /// This method just creates a <see cref="DatasetReference"/> and delegates to <see cref="CreateDataset(DatasetReference,CreateDatasetOptions)"/>.
 /// </summary>
 /// <param name="datasetId">The new dataset ID. Must not be null.</param>
 /// <param name="options">The options for the operation. May be null, in which case defaults will be supplied.</param>
 /// <returns>The created dataset.</returns>
 public virtual BigQueryDataset CreateDataset(string datasetId, CreateDatasetOptions options = null) =>
 CreateDataset(GetDatasetReference(datasetId), options);
 /// <inheritdoc />
 public override BigQueryDataset GetOrCreateDataset(DatasetReference datasetReference, Dataset resource = null, GetDatasetOptions getOptions = null, CreateDatasetOptions createOptions = null)
 {
     GaxPreconditions.CheckNotNull(datasetReference, nameof(datasetReference));
     GaxPreconditions.CheckArgument(
         resource?.DatasetReference == null || datasetReference.ReferencesSameAs(resource.DatasetReference),
         nameof(resource.DatasetReference),
         $"If {nameof(resource.DatasetReference)} is specified, it must be the same as {nameof(datasetReference)}");
     try
     {
         return(GetDataset(datasetReference, getOptions));
     }
     catch (GoogleApiException ex) when(ex.HttpStatusCode == HttpStatusCode.NotFound)
     {
         return(CreateDataset(datasetReference, resource, createOptions));
     }
 }