@@ -106,6 +106,67 @@ def self.cross_network_automation_service_available? version: :v1
106106 false
107107 end
108108
109+ ##
110+ # Create a new client object for DataTransferService.
111+ #
112+ # By default, this returns an instance of
113+ # [Google::Cloud::NetworkConnectivity::V1::DataTransferService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-network_connectivity-v1/latest/Google-Cloud-NetworkConnectivity-V1-DataTransferService-Client)
114+ # for a gRPC client for version V1 of the API.
115+ # However, you can specify a different API version by passing it in the
116+ # `version` parameter. If the DataTransferService service is
117+ # supported by that API version, and the corresponding gem is available, the
118+ # appropriate versioned client will be returned.
119+ #
120+ # Raises an exception if the currently installed versioned client gem for the
121+ # given API version does not support the DataTransferService service.
122+ # You can determine whether the method will succeed by calling
123+ # {Google::Cloud::NetworkConnectivity.data_transfer_service_available?}.
124+ #
125+ # ## About DataTransferService
126+ #
127+ # DataTransferService is the service for the Data Transfer API.
128+ #
129+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
130+ # Defaults to `:v1`.
131+ # @return [::Object] A client object for the specified version.
132+ #
133+ def self . data_transfer_service version : :v1 , &block
134+ require "google/cloud/network_connectivity/#{ version . to_s . downcase } "
135+
136+ package_name = Google ::Cloud ::NetworkConnectivity
137+ . constants
138+ . select { |sym | sym . to_s . downcase == version . to_s . downcase . tr ( "_" , "" ) }
139+ . first
140+ service_module = Google ::Cloud ::NetworkConnectivity . const_get ( package_name ) . const_get ( :DataTransferService )
141+ service_module . const_get ( :Client ) . new ( &block )
142+ end
143+
144+ ##
145+ # Determines whether the DataTransferService service is supported by the current client.
146+ # If true, you can retrieve a client object by calling {Google::Cloud::NetworkConnectivity.data_transfer_service}.
147+ # If false, that method will raise an exception. This could happen if the given
148+ # API version does not exist or does not support the DataTransferService service,
149+ # or if the versioned client gem needs an update to support the DataTransferService service.
150+ #
151+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
152+ # Defaults to `:v1`.
153+ # @return [boolean] Whether the service is available.
154+ #
155+ def self . data_transfer_service_available? version : :v1
156+ require "google/cloud/network_connectivity/#{ version . to_s . downcase } "
157+ package_name = Google ::Cloud ::NetworkConnectivity
158+ . constants
159+ . select { |sym | sym . to_s . downcase == version . to_s . downcase . tr ( "_" , "" ) }
160+ . first
161+ return false unless package_name
162+ service_module = Google ::Cloud ::NetworkConnectivity . const_get package_name
163+ return false unless service_module . const_defined? :DataTransferService
164+ service_module = service_module . const_get :DataTransferService
165+ service_module . const_defined? :Client
166+ rescue ::LoadError
167+ false
168+ end
169+
109170 ##
110171 # Create a new client object for HubService.
111172 #
0 commit comments