lib/google/cloud/run.rb in google-cloud-run-client-1.2.1 vs lib/google/cloud/run.rb in google-cloud-run-client-1.3.0
- old
+ new
@@ -44,9 +44,43 @@
module Google
module Cloud
module Run
##
+ # Create a new client object for Builds.
+ #
+ # By default, this returns an instance of
+ # [Google::Cloud::Run::V2::Builds::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-run-v2/latest/Google-Cloud-Run-V2-Builds-Client)
+ # for a gRPC client for version V2 of the API.
+ # However, you can specify a different API version by passing it in the
+ # `version` parameter. If the Builds service is
+ # supported by that API version, and the corresponding gem is available, the
+ # appropriate versioned client will be returned.
+ # You can also specify a different transport by passing `:rest` or `:grpc` in
+ # the `transport` parameter.
+ #
+ # ## About Builds
+ #
+ # Cloud Run Build Control Plane API
+ #
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
+ # Defaults to `:v2`.
+ # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
+ # @return [::Object] A client object for the specified version.
+ #
+ def self.builds version: :v2, transport: :grpc, &block
+ require "google/cloud/run/#{version.to_s.downcase}"
+
+ package_name = Google::Cloud::Run
+ .constants
+ .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
+ .first
+ service_module = Google::Cloud::Run.const_get(package_name).const_get(:Builds)
+ service_module = service_module.const_get(:Rest) if transport == :rest
+ service_module.const_get(:Client).new(&block)
+ end
+
+ ##
# Create a new client object for Executions.
#
# By default, this returns an instance of
# [Google::Cloud::Run::V2::Executions::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-run-v2/latest/Google-Cloud-Run-V2-Executions-Client)
# for a gRPC client for version V2 of the API.