Skip to content

Commit 29e5b13

Browse files
feat: Add UnenrollDataSources API which gives users a programmatic way to unenroll data sources (#24810)
1 parent 2eebc55 commit 29e5b13

File tree

12 files changed

+478
-1
lines changed

12 files changed

+478
-1
lines changed

google-cloud-bigquery-data_transfer-v1/.owlbot-manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"snippets/data_transfer_service/list_transfer_runs.rb",
5959
"snippets/data_transfer_service/schedule_transfer_runs.rb",
6060
"snippets/data_transfer_service/start_manual_transfer_runs.rb",
61+
"snippets/data_transfer_service/unenroll_data_sources.rb",
6162
"snippets/data_transfer_service/update_transfer_config.rb",
6263
"snippets/snippet_metadata_google.cloud.bigquery.datatransfer.v1.json",
6364
"test/google/cloud/bigquery/data_transfer/v1/data_transfer_service_paths_test.rb",

google-cloud-bigquery-data_transfer-v1/gapic_metadata.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@
8484
"methods": [
8585
"enroll_data_sources"
8686
]
87+
},
88+
"UnenrollDataSources": {
89+
"methods": [
90+
"unenroll_data_sources"
91+
]
8792
}
8893
}
8994
}

google-cloud-bigquery-data_transfer-v1/lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service/client.rb

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,97 @@ def enroll_data_sources request, options = nil
17221722
raise ::Google::Cloud::Error.from_error(e)
17231723
end
17241724

1725+
##
1726+
# Unenroll data sources in a user project. This allows users to remove
1727+
# transfer configurations for these data sources. They will no longer appear
1728+
# in the ListDataSources RPC and will also no longer appear in the [BigQuery
1729+
# UI](https://console.cloud.google.com/bigquery).
1730+
#
1731+
# @overload unenroll_data_sources(request, options = nil)
1732+
# Pass arguments to `unenroll_data_sources` via a request object, either of type
1733+
# {::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest} or an equivalent Hash.
1734+
#
1735+
# @param request [::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest, ::Hash]
1736+
# A request object representing the call parameters. Required. To specify no
1737+
# parameters, or to keep all the default parameter values, pass an empty Hash.
1738+
# @param options [::Gapic::CallOptions, ::Hash]
1739+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
1740+
#
1741+
# @overload unenroll_data_sources(name: nil, data_source_ids: nil)
1742+
# Pass arguments to `unenroll_data_sources` via keyword arguments. Note that at
1743+
# least one keyword argument is required. To specify no parameters, or to keep all
1744+
# the default parameter values, pass an empty Hash as a request object (see above).
1745+
#
1746+
# @param name [::String]
1747+
# The name of the project resource in the form: `projects/{project_id}`
1748+
# @param data_source_ids [::Array<::String>]
1749+
# Data sources that are unenrolled. It is required to provide at least one
1750+
# data source id.
1751+
#
1752+
# @yield [response, operation] Access the result along with the RPC operation
1753+
# @yieldparam response [::Google::Protobuf::Empty]
1754+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
1755+
#
1756+
# @return [::Google::Protobuf::Empty]
1757+
#
1758+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
1759+
#
1760+
# @example Basic example
1761+
# require "google/cloud/bigquery/data_transfer/v1"
1762+
#
1763+
# # Create a client object. The client can be reused for multiple calls.
1764+
# client = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferService::Client.new
1765+
#
1766+
# # Create a request. To set request fields, pass in keyword arguments.
1767+
# request = Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest.new
1768+
#
1769+
# # Call the unenroll_data_sources method.
1770+
# result = client.unenroll_data_sources request
1771+
#
1772+
# # The returned object is of type Google::Protobuf::Empty.
1773+
# p result
1774+
#
1775+
def unenroll_data_sources request, options = nil
1776+
raise ::ArgumentError, "request must be provided" if request.nil?
1777+
1778+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest
1779+
1780+
# Converts hash and nil to an options object
1781+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1782+
1783+
# Customize the options with defaults
1784+
metadata = @config.rpcs.unenroll_data_sources.metadata.to_h
1785+
1786+
# Set x-goog-api-client and x-goog-user-project headers
1787+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1788+
lib_name: @config.lib_name, lib_version: @config.lib_version,
1789+
gapic_version: ::Google::Cloud::Bigquery::DataTransfer::V1::VERSION
1790+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1791+
1792+
header_params = {}
1793+
if request.name
1794+
header_params["name"] = request.name
1795+
end
1796+
1797+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
1798+
metadata[:"x-goog-request-params"] ||= request_params_header
1799+
1800+
options.apply_defaults timeout: @config.rpcs.unenroll_data_sources.timeout,
1801+
metadata: metadata,
1802+
retry_policy: @config.rpcs.unenroll_data_sources.retry_policy
1803+
1804+
options.apply_defaults timeout: @config.timeout,
1805+
metadata: @config.metadata,
1806+
retry_policy: @config.retry_policy
1807+
1808+
@data_transfer_service_stub.call_rpc :unenroll_data_sources, request, options: options do |response, operation|
1809+
yield response, operation if block_given?
1810+
return response
1811+
end
1812+
rescue ::GRPC::BadStatus => e
1813+
raise ::Google::Cloud::Error.from_error(e)
1814+
end
1815+
17251816
##
17261817
# Configuration class for the DataTransferService API.
17271818
#
@@ -1950,6 +2041,11 @@ class Rpcs
19502041
# @return [::Gapic::Config::Method]
19512042
#
19522043
attr_reader :enroll_data_sources
2044+
##
2045+
# RPC-specific configuration for `unenroll_data_sources`
2046+
# @return [::Gapic::Config::Method]
2047+
#
2048+
attr_reader :unenroll_data_sources
19532049

19542050
# @private
19552051
def initialize parent_rpcs = nil
@@ -1983,6 +2079,8 @@ def initialize parent_rpcs = nil
19832079
@check_valid_creds = ::Gapic::Config::Method.new check_valid_creds_config
19842080
enroll_data_sources_config = parent_rpcs.enroll_data_sources if parent_rpcs.respond_to? :enroll_data_sources
19852081
@enroll_data_sources = ::Gapic::Config::Method.new enroll_data_sources_config
2082+
unenroll_data_sources_config = parent_rpcs.unenroll_data_sources if parent_rpcs.respond_to? :unenroll_data_sources
2083+
@unenroll_data_sources = ::Gapic::Config::Method.new unenroll_data_sources_config
19862084

19872085
yield self if block_given?
19882086
end

google-cloud-bigquery-data_transfer-v1/lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service/rest/client.rb

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,90 @@ def enroll_data_sources request, options = nil
16091609
raise ::Google::Cloud::Error.from_error(e)
16101610
end
16111611

1612+
##
1613+
# Unenroll data sources in a user project. This allows users to remove
1614+
# transfer configurations for these data sources. They will no longer appear
1615+
# in the ListDataSources RPC and will also no longer appear in the [BigQuery
1616+
# UI](https://console.cloud.google.com/bigquery).
1617+
#
1618+
# @overload unenroll_data_sources(request, options = nil)
1619+
# Pass arguments to `unenroll_data_sources` via a request object, either of type
1620+
# {::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest} or an equivalent Hash.
1621+
#
1622+
# @param request [::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest, ::Hash]
1623+
# A request object representing the call parameters. Required. To specify no
1624+
# parameters, or to keep all the default parameter values, pass an empty Hash.
1625+
# @param options [::Gapic::CallOptions, ::Hash]
1626+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
1627+
#
1628+
# @overload unenroll_data_sources(name: nil, data_source_ids: nil)
1629+
# Pass arguments to `unenroll_data_sources` via keyword arguments. Note that at
1630+
# least one keyword argument is required. To specify no parameters, or to keep all
1631+
# the default parameter values, pass an empty Hash as a request object (see above).
1632+
#
1633+
# @param name [::String]
1634+
# The name of the project resource in the form: `projects/{project_id}`
1635+
# @param data_source_ids [::Array<::String>]
1636+
# Data sources that are unenrolled. It is required to provide at least one
1637+
# data source id.
1638+
# @yield [result, operation] Access the result along with the TransportOperation object
1639+
# @yieldparam result [::Google::Protobuf::Empty]
1640+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
1641+
#
1642+
# @return [::Google::Protobuf::Empty]
1643+
#
1644+
# @raise [::Google::Cloud::Error] if the REST call is aborted.
1645+
#
1646+
# @example Basic example
1647+
# require "google/cloud/bigquery/data_transfer/v1"
1648+
#
1649+
# # Create a client object. The client can be reused for multiple calls.
1650+
# client = Google::Cloud::Bigquery::DataTransfer::V1::DataTransferService::Rest::Client.new
1651+
#
1652+
# # Create a request. To set request fields, pass in keyword arguments.
1653+
# request = Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest.new
1654+
#
1655+
# # Call the unenroll_data_sources method.
1656+
# result = client.unenroll_data_sources request
1657+
#
1658+
# # The returned object is of type Google::Protobuf::Empty.
1659+
# p result
1660+
#
1661+
def unenroll_data_sources request, options = nil
1662+
raise ::ArgumentError, "request must be provided" if request.nil?
1663+
1664+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest
1665+
1666+
# Converts hash and nil to an options object
1667+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
1668+
1669+
# Customize the options with defaults
1670+
call_metadata = @config.rpcs.unenroll_data_sources.metadata.to_h
1671+
1672+
# Set x-goog-api-client and x-goog-user-project headers
1673+
call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
1674+
lib_name: @config.lib_name, lib_version: @config.lib_version,
1675+
gapic_version: ::Google::Cloud::Bigquery::DataTransfer::V1::VERSION,
1676+
transports_version_send: [:rest]
1677+
1678+
call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
1679+
1680+
options.apply_defaults timeout: @config.rpcs.unenroll_data_sources.timeout,
1681+
metadata: call_metadata,
1682+
retry_policy: @config.rpcs.unenroll_data_sources.retry_policy
1683+
1684+
options.apply_defaults timeout: @config.timeout,
1685+
metadata: @config.metadata,
1686+
retry_policy: @config.retry_policy
1687+
1688+
@data_transfer_service_stub.unenroll_data_sources request, options do |result, operation|
1689+
yield result, operation if block_given?
1690+
return result
1691+
end
1692+
rescue ::Gapic::Rest::Error => e
1693+
raise ::Google::Cloud::Error.from_error(e)
1694+
end
1695+
16121696
##
16131697
# Configuration class for the DataTransferService REST API.
16141698
#
@@ -1824,6 +1908,11 @@ class Rpcs
18241908
# @return [::Gapic::Config::Method]
18251909
#
18261910
attr_reader :enroll_data_sources
1911+
##
1912+
# RPC-specific configuration for `unenroll_data_sources`
1913+
# @return [::Gapic::Config::Method]
1914+
#
1915+
attr_reader :unenroll_data_sources
18271916

18281917
# @private
18291918
def initialize parent_rpcs = nil
@@ -1857,6 +1946,8 @@ def initialize parent_rpcs = nil
18571946
@check_valid_creds = ::Gapic::Config::Method.new check_valid_creds_config
18581947
enroll_data_sources_config = parent_rpcs.enroll_data_sources if parent_rpcs.respond_to? :enroll_data_sources
18591948
@enroll_data_sources = ::Gapic::Config::Method.new enroll_data_sources_config
1949+
unenroll_data_sources_config = parent_rpcs.unenroll_data_sources if parent_rpcs.respond_to? :unenroll_data_sources
1950+
@unenroll_data_sources = ::Gapic::Config::Method.new unenroll_data_sources_config
18601951

18611952
yield self if block_given?
18621953
end

google-cloud-bigquery-data_transfer-v1/lib/google/cloud/bigquery/data_transfer/v1/data_transfer_service/rest/service_stub.rb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,44 @@ def enroll_data_sources request_pb, options = nil
632632
result
633633
end
634634

635+
##
636+
# Baseline implementation for the unenroll_data_sources REST call
637+
#
638+
# @param request_pb [::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest]
639+
# A request object representing the call parameters. Required.
640+
# @param options [::Gapic::CallOptions]
641+
# Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
642+
#
643+
# @yield [result, operation] Access the result along with the TransportOperation object
644+
# @yieldparam result [::Google::Protobuf::Empty]
645+
# @yieldparam operation [::Gapic::Rest::TransportOperation]
646+
#
647+
# @return [::Google::Protobuf::Empty]
648+
# A result object deserialized from the server's reply
649+
def unenroll_data_sources request_pb, options = nil
650+
raise ::ArgumentError, "request must be provided" if request_pb.nil?
651+
652+
verb, uri, query_string_params, body = ServiceStub.transcode_unenroll_data_sources_request request_pb
653+
query_string_params = if query_string_params.any?
654+
query_string_params.to_h { |p| p.split "=", 2 }
655+
else
656+
{}
657+
end
658+
659+
response = @client_stub.make_http_request(
660+
verb,
661+
uri: uri,
662+
body: body || "",
663+
params: query_string_params,
664+
options: options
665+
)
666+
operation = ::Gapic::Rest::TransportOperation.new response
667+
result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true
668+
669+
yield result, operation if block_given?
670+
result
671+
end
672+
635673
##
636674
# @private
637675
#
@@ -1063,6 +1101,28 @@ def self.transcode_enroll_data_sources_request request_pb
10631101
)
10641102
transcoder.transcode request_pb
10651103
end
1104+
1105+
##
1106+
# @private
1107+
#
1108+
# GRPC transcoding helper method for the unenroll_data_sources REST call
1109+
#
1110+
# @param request_pb [::Google::Cloud::Bigquery::DataTransfer::V1::UnenrollDataSourcesRequest]
1111+
# A request object representing the call parameters. Required.
1112+
# @return [Array(String, [String, nil], Hash{String => String})]
1113+
# Uri, Body, Query string parameters
1114+
def self.transcode_unenroll_data_sources_request request_pb
1115+
transcoder = Gapic::Rest::GrpcTranscoder.new
1116+
.with_bindings(
1117+
uri_method: :post,
1118+
uri_template: "/v1/{name}:unenrollDataSources",
1119+
body: "*",
1120+
matches: [
1121+
["name", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
1122+
]
1123+
)
1124+
transcoder.transcode request_pb
1125+
end
10661126
end
10671127
end
10681128
end

0 commit comments

Comments
 (0)