From 00a70fab810cb57e4b4ce76d512d94270777d21f Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Thu, 10 Aug 2017 14:53:00 +0100 Subject: [PATCH] First sample generated methods Everything in the body of BigQueryClient.DatasetLabels.cs after the first line (comment) is autogenerated. The remaining work for these features will be: - Implementation in BigQueryDatasetImpl - Options test - Snippets - Methods in BigQueryDataset.cs (we may improve the generator to do these later...) - Integration tests --- .../Methods/ClearDatasetLabels.xml | 13 + .../Methods/ModifyDatasetLabels.xml | 26 ++ .../Methods/RemoveDatasetLabel.xml | 18 + .../Methods/SetDatasetLabel.xml | 24 + .../generateoverloads.sh | 7 + .../BigQueryClient.DatasetLabels.cs | 416 ++++++++++++++++++ .../ModifyLabelsOptions.cs | 63 +++ 7 files changed, 567 insertions(+) create mode 100644 apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ClearDatasetLabels.xml create mode 100644 apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ModifyDatasetLabels.xml create mode 100644 apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/RemoveDatasetLabel.xml create mode 100644 apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/SetDatasetLabel.xml create mode 100755 apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/generateoverloads.sh create mode 100644 apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/BigQueryClient.DatasetLabels.cs create mode 100644 apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/ModifyLabelsOptions.cs diff --git a/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ClearDatasetLabels.xml b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ClearDatasetLabels.xml new file mode 100644 index 000000000000..00f1db1d8dda --- /dev/null +++ b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ClearDatasetLabels.xml @@ -0,0 +1,13 @@ + + + + + + Clears all labels on {target}. + + A dictionary with the labels on the dataset before they were cleared. + + + \ No newline at end of file diff --git a/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ModifyDatasetLabels.xml b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ModifyDatasetLabels.xml new file mode 100644 index 000000000000..0bed00a8ad07 --- /dev/null +++ b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/ModifyDatasetLabels.xml @@ -0,0 +1,26 @@ + + + + + + + + + + Sets or removes one or more labels on {target}. + + + Each entry in is treated as a label to set or remove. If the value is null, + it will be removed from the bucket; otherwise, it will be set/added. Labels which do not have an entry + in the dictionary will be ignored. + + + A dictionary with the same keys as , and values indicating the corresponding label value + before this operation completed. Labels which weren't present on the bucket before the modification have corresponding + null values in the returned dictionary. + + + + \ No newline at end of file diff --git a/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/RemoveDatasetLabel.xml b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/RemoveDatasetLabel.xml new file mode 100644 index 000000000000..e2acd7c2d3ec --- /dev/null +++ b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/RemoveDatasetLabel.xml @@ -0,0 +1,18 @@ + + + + + + + + + + Removes a label from a bucket, if it previously existed. It is not an error to + attempt to remove a label that doesn't already exist. + + The previous value of the label, or null if the label was not previously set. + + + \ No newline at end of file diff --git a/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/SetDatasetLabel.xml b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/SetDatasetLabel.xml new file mode 100644 index 000000000000..2edf5336cc38 --- /dev/null +++ b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/Methods/SetDatasetLabel.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + Sets the value for a single label on a dataset. The label will be added if it does + not exist, or updated if it already exists. + + + + The dataset is first fetched to retrieve the current values, then a patch call is made. + + + The previous value of the label, or null if the label was not previously set. + + + \ No newline at end of file diff --git a/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/generateoverloads.sh b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/generateoverloads.sh new file mode 100755 index 000000000000..d0e89de86673 --- /dev/null +++ b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2.GenerateOverloads/generateoverloads.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +declare -r CLIENT=../Google.Cloud.BigQuery.V2/BigQueryClient +dotnet run -- Methods/SetDatasetLabel.xml $CLIENT.DatasetLabels.cs +dotnet run -- Methods/RemoveDatasetLabel.xml $CLIENT.DatasetLabels.cs +dotnet run -- Methods/ClearDatasetLabels.xml $CLIENT.DatasetLabels.cs +dotnet run -- Methods/ModifyDatasetLabels.xml $CLIENT.DatasetLabels.cs \ No newline at end of file diff --git a/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/BigQueryClient.DatasetLabels.cs b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/BigQueryClient.DatasetLabels.cs new file mode 100644 index 000000000000..ff20acc813d1 --- /dev/null +++ b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/BigQueryClient.DatasetLabels.cs @@ -0,0 +1,416 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Google.Apis.Bigquery.v2.Data; +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Google.Cloud.BigQuery.V2 +{ + public abstract partial class BigQueryClient + { + // Methods modifying labels on datasets + +#region SetDatasetLabel + /// + /// Sets the value for a single label on a dataset. The label will be added if it does + /// not exist, or updated if it already exists. + /// This method just creates a and delegates to . + /// + /// + /// + /// The dataset is first fetched to retrieve the current values, then a patch call is made. + /// + /// + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The new value of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The previous value of the label, or null if the label was not previously set. + public virtual string SetDatasetLabel(string datasetId, string labelName, string labelValue, ModifyLabelsOptions options = null) => + SetDatasetLabel(GetDatasetReference(datasetId), labelName, labelValue, options); + + /// + /// Sets the value for a single label on a dataset. The label will be added if it does + /// not exist, or updated if it already exists. + /// This method just creates a and delegates to . + /// + /// + /// + /// The dataset is first fetched to retrieve the current values, then a patch call is made. + /// + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The new value of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The previous value of the label, or null if the label was not previously set. + public virtual string SetDatasetLabel(string projectId, string datasetId, string labelName, string labelValue, ModifyLabelsOptions options = null) => + SetDatasetLabel(GetDatasetReference(projectId, datasetId), labelName, labelValue, options); + + /// + /// Sets the value for a single label on a dataset. The label will be added if it does + /// not exist, or updated if it already exists. + /// + /// + /// + /// The dataset is first fetched to retrieve the current values, then a patch call is made. + /// + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The name of the label. Must not be null. + /// The new value of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The previous value of the label, or null if the label was not previously set. + public virtual string SetDatasetLabel(DatasetReference datasetReference, string labelName, string labelValue, ModifyLabelsOptions options = null) => + throw new NotImplementedException(); + + /// + /// Sets the value for a single label on a dataset. The label will be added if it does + /// not exist, or updated if it already exists. + /// This method just creates a and delegates to . + /// + /// + /// + /// The dataset is first fetched to retrieve the current values, then a patch call is made. + /// + /// + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The new value of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// the previous value of the label, or null if the label was not previously set. + public virtual Task SetDatasetLabelAsync(string datasetId, string labelName, string labelValue, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + SetDatasetLabelAsync(GetDatasetReference(datasetId), labelName, labelValue, options, cancellationToken); + + /// + /// Sets the value for a single label on a dataset. The label will be added if it does + /// not exist, or updated if it already exists. + /// This method just creates a and delegates to . + /// + /// + /// + /// The dataset is first fetched to retrieve the current values, then a patch call is made. + /// + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The new value of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// the previous value of the label, or null if the label was not previously set. + public virtual Task SetDatasetLabelAsync(string projectId, string datasetId, string labelName, string labelValue, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + SetDatasetLabelAsync(GetDatasetReference(projectId, datasetId), labelName, labelValue, options, cancellationToken); + + /// + /// Sets the value for a single label on a dataset. The label will be added if it does + /// not exist, or updated if it already exists. + /// + /// + /// + /// The dataset is first fetched to retrieve the current values, then a patch call is made. + /// + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The name of the label. Must not be null. + /// The new value of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// the previous value of the label, or null if the label was not previously set. + public virtual Task SetDatasetLabelAsync(DatasetReference datasetReference, string labelName, string labelValue, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + throw new NotImplementedException(); +#endregion + +#region RemoveDatasetLabel + /// + /// Removes a label from a bucket, if it previously existed. It is not an error to + /// attempt to remove a label that doesn't already exist. + /// This method just creates a and delegates to . + /// + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The previous value of the label, or null if the label was not previously set. + public virtual string RemoveDatasetLabel(string datasetId, string labelName, ModifyLabelsOptions options = null) => + RemoveDatasetLabel(GetDatasetReference(datasetId), labelName, options); + + /// + /// Removes a label from a bucket, if it previously existed. It is not an error to + /// attempt to remove a label that doesn't already exist. + /// This method just creates a and delegates to . + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The previous value of the label, or null if the label was not previously set. + public virtual string RemoveDatasetLabel(string projectId, string datasetId, string labelName, ModifyLabelsOptions options = null) => + RemoveDatasetLabel(GetDatasetReference(projectId, datasetId), labelName, options); + + /// + /// Removes a label from a bucket, if it previously existed. It is not an error to + /// attempt to remove a label that doesn't already exist. + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The name of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The previous value of the label, or null if the label was not previously set. + public virtual string RemoveDatasetLabel(DatasetReference datasetReference, string labelName, ModifyLabelsOptions options = null) => + throw new NotImplementedException(); + + /// + /// Removes a label from a bucket, if it previously existed. It is not an error to + /// attempt to remove a label that doesn't already exist. + /// This method just creates a and delegates to . + /// + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// the previous value of the label, or null if the label was not previously set. + public virtual Task RemoveDatasetLabelAsync(string datasetId, string labelName, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + RemoveDatasetLabelAsync(GetDatasetReference(datasetId), labelName, options, cancellationToken); + + /// + /// Removes a label from a bucket, if it previously existed. It is not an error to + /// attempt to remove a label that doesn't already exist. + /// This method just creates a and delegates to . + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The name of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// the previous value of the label, or null if the label was not previously set. + public virtual Task RemoveDatasetLabelAsync(string projectId, string datasetId, string labelName, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + RemoveDatasetLabelAsync(GetDatasetReference(projectId, datasetId), labelName, options, cancellationToken); + + /// + /// Removes a label from a bucket, if it previously existed. It is not an error to + /// attempt to remove a label that doesn't already exist. + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The name of the label. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// the previous value of the label, or null if the label was not previously set. + public virtual Task RemoveDatasetLabelAsync(DatasetReference datasetReference, string labelName, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + throw new NotImplementedException(); +#endregion + +#region ClearDatasetLabels + /// + /// Clears all labels on the specified dataset. + /// This method just creates a and delegates to . + /// + /// The dataset ID. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// A dictionary with the labels on the dataset before they were cleared. + public virtual IDictionary ClearDatasetLabels(string datasetId, ModifyLabelsOptions options = null) => + ClearDatasetLabels(GetDatasetReference(datasetId), options); + + /// + /// Clears all labels on the specified dataset within this client's project. + /// This method just creates a and delegates to . + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// A dictionary with the labels on the dataset before they were cleared. + public virtual IDictionary ClearDatasetLabels(string projectId, string datasetId, ModifyLabelsOptions options = null) => + ClearDatasetLabels(GetDatasetReference(projectId, datasetId), options); + + /// + /// Clears all labels on the specified dataset. + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// A dictionary with the labels on the dataset before they were cleared. + public virtual IDictionary ClearDatasetLabels(DatasetReference datasetReference, ModifyLabelsOptions options = null) => + throw new NotImplementedException(); + + /// + /// Clears all labels on the specified dataset. + /// This method just creates a and delegates to . + /// + /// The dataset ID. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// a dictionary with the labels on the dataset before they were cleared. + public virtual Task> ClearDatasetLabelsAsync(string datasetId, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + ClearDatasetLabelsAsync(GetDatasetReference(datasetId), options, cancellationToken); + + /// + /// Clears all labels on the specified dataset within this client's project. + /// This method just creates a and delegates to . + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// a dictionary with the labels on the dataset before they were cleared. + public virtual Task> ClearDatasetLabelsAsync(string projectId, string datasetId, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + ClearDatasetLabelsAsync(GetDatasetReference(projectId, datasetId), options, cancellationToken); + + /// + /// Clears all labels on the specified dataset. + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// a dictionary with the labels on the dataset before they were cleared. + public virtual Task> ClearDatasetLabelsAsync(DatasetReference datasetReference, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + throw new NotImplementedException(); +#endregion + +#region ModifyDatasetLabels + /// + /// Sets or removes one or more labels on the specified dataset. + /// This method just creates a and delegates to . + /// + /// + /// Each entry in is treated as a label to set or remove. If the value is null, + /// it will be removed from the bucket; otherwise, it will be set/added. Labels which do not have an entry + /// in the dictionary will be ignored. + /// + /// The dataset ID. Must not be null. + /// The labels to set. Must contain at least one entry; keys must not be null, but values may be (indicating label removal). + /// The options for the operation. May be null, in which case defaults will be supplied. + /// + /// A dictionary with the same keys as , and values indicating the corresponding label value + /// before this operation completed. Labels which weren't present on the bucket before the modification have corresponding + /// null values in the returned dictionary. + /// + public virtual IDictionary ModifyDatasetLabels(string datasetId, IDictionary labels, ModifyLabelsOptions options = null) => + ModifyDatasetLabels(GetDatasetReference(datasetId), labels, options); + + /// + /// Sets or removes one or more labels on the specified dataset within this client's project. + /// This method just creates a and delegates to . + /// + /// + /// Each entry in is treated as a label to set or remove. If the value is null, + /// it will be removed from the bucket; otherwise, it will be set/added. Labels which do not have an entry + /// in the dictionary will be ignored. + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The labels to set. Must contain at least one entry; keys must not be null, but values may be (indicating label removal). + /// The options for the operation. May be null, in which case defaults will be supplied. + /// + /// A dictionary with the same keys as , and values indicating the corresponding label value + /// before this operation completed. Labels which weren't present on the bucket before the modification have corresponding + /// null values in the returned dictionary. + /// + public virtual IDictionary ModifyDatasetLabels(string projectId, string datasetId, IDictionary labels, ModifyLabelsOptions options = null) => + ModifyDatasetLabels(GetDatasetReference(projectId, datasetId), labels, options); + + /// + /// Sets or removes one or more labels on the specified dataset. + /// + /// + /// Each entry in is treated as a label to set or remove. If the value is null, + /// it will be removed from the bucket; otherwise, it will be set/added. Labels which do not have an entry + /// in the dictionary will be ignored. + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The labels to set. Must contain at least one entry; keys must not be null, but values may be (indicating label removal). + /// The options for the operation. May be null, in which case defaults will be supplied. + /// + /// A dictionary with the same keys as , and values indicating the corresponding label value + /// before this operation completed. Labels which weren't present on the bucket before the modification have corresponding + /// null values in the returned dictionary. + /// + public virtual IDictionary ModifyDatasetLabels(DatasetReference datasetReference, IDictionary labels, ModifyLabelsOptions options = null) => + throw new NotImplementedException(); + + /// + /// Sets or removes one or more labels on the specified dataset. + /// This method just creates a and delegates to . + /// + /// + /// Each entry in is treated as a label to set or remove. If the value is null, + /// it will be removed from the bucket; otherwise, it will be set/added. Labels which do not have an entry + /// in the dictionary will be ignored. + /// + /// The dataset ID. Must not be null. + /// The labels to set. Must contain at least one entry; keys must not be null, but values may be (indicating label removal). + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// a dictionary with the same keys as , and values indicating the corresponding label value + /// before this operation completed. Labels which weren't present on the bucket before the modification have corresponding + /// null values in the returned dictionary. + /// + public virtual Task> ModifyDatasetLabelsAsync(string datasetId, IDictionary labels, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + ModifyDatasetLabelsAsync(GetDatasetReference(datasetId), labels, options, cancellationToken); + + /// + /// Sets or removes one or more labels on the specified dataset within this client's project. + /// This method just creates a and delegates to . + /// + /// + /// Each entry in is treated as a label to set or remove. If the value is null, + /// it will be removed from the bucket; otherwise, it will be set/added. Labels which do not have an entry + /// in the dictionary will be ignored. + /// + /// The project ID. Must not be null. + /// The dataset ID. Must not be null. + /// The labels to set. Must contain at least one entry; keys must not be null, but values may be (indicating label removal). + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// a dictionary with the same keys as , and values indicating the corresponding label value + /// before this operation completed. Labels which weren't present on the bucket before the modification have corresponding + /// null values in the returned dictionary. + /// + public virtual Task> ModifyDatasetLabelsAsync(string projectId, string datasetId, IDictionary labels, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + ModifyDatasetLabelsAsync(GetDatasetReference(projectId, datasetId), labels, options, cancellationToken); + + /// + /// Sets or removes one or more labels on the specified dataset. + /// + /// + /// Each entry in is treated as a label to set or remove. If the value is null, + /// it will be removed from the bucket; otherwise, it will be set/added. Labels which do not have an entry + /// in the dictionary will be ignored. + /// + /// A fully-qualified identifier for the dataset. Must not be null. + /// The labels to set. Must contain at least one entry; keys must not be null, but values may be (indicating label removal). + /// The options for the operation. May be null, in which case defaults will be supplied. + /// The token to monitor for cancellation requests. + /// A task representing the asynchronous operation. When complete, the result is + /// a dictionary with the same keys as , and values indicating the corresponding label value + /// before this operation completed. Labels which weren't present on the bucket before the modification have corresponding + /// null values in the returned dictionary. + /// + public virtual Task> ModifyDatasetLabelsAsync(DatasetReference datasetReference, IDictionary labels, ModifyLabelsOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) => + throw new NotImplementedException(); +#endregion + } +} diff --git a/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/ModifyLabelsOptions.cs b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/ModifyLabelsOptions.cs new file mode 100644 index 000000000000..95fdffa2f32a --- /dev/null +++ b/apis/Google.Cloud.BigQuery.V2/Google.Cloud.BigQuery.V2/ModifyLabelsOptions.cs @@ -0,0 +1,63 @@ +// Copyright 2016 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using Google.Api.Gax; + +namespace Google.Cloud.BigQuery.V2 +{ + /// + /// Options used when modifying labels. + /// + public sealed class ModifyLabelsOptions + { + /// + /// The default number of retries. + /// + internal const int DefaultRetries = 3; + + /// + /// Precondition for modification: the labels are only modified if its current + /// etag matches the given value. + /// + public string ETag { get; set; } + + private int? _retries; + + /// + /// The number of times to retry the modification if the etag changes + /// in the read/modify/write cycle. If this property is not set, a suitable default is used. + /// The value must not be negative. + /// + /// + /// Modifying labels involves reading the resource in one request, + /// then sending another request with the new labels, including an etag check + /// to ensure that the bucket hasn't changed between the two requests. If the etag + /// *has* changed, the overall operation can be retried from the start. This property indicates + /// the number of retries, so it has a minimum value of 0. + /// + public int? Retries + { + get => _retries; + set + { + if (value < 0) // False for null implicitly + { + // Simplest way to get the right exception... + GaxPreconditions.CheckArgumentRange(value.Value, nameof(value), 0, int.MaxValue); + } + _retries = value; + } + } + } +}