diff --git a/google-ads-data_manager/lib/google/ads/data_manager.rb b/google-ads-data_manager/lib/google/ads/data_manager.rb index dbdd4aa508cf..716f33ea0689 100644 --- a/google-ads-data_manager/lib/google/ads/data_manager.rb +++ b/google-ads-data_manager/lib/google/ads/data_manager.rb @@ -96,6 +96,366 @@ def self.ingestion_service_available? version: :v1, transport: :grpc rescue ::LoadError false end + + ## + # Create a new client object for MarketingDataInsightsService. + # + # By default, this returns an instance of + # [Google::Ads::DataManager::V1::MarketingDataInsightsService::Client](https://rubydoc.info/gems/google-ads-data_manager-v1/Google/Ads/DataManager/V1/MarketingDataInsightsService/Client) + # for a gRPC client for version V1 of the API. + # However, you can specify a different API version by passing it in the + # `version` parameter. If the MarketingDataInsightsService 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. + # + # Raises an exception if the currently installed versioned client gem for the + # given API version does not support the given transport of the MarketingDataInsightsService service. + # You can determine whether the method will succeed by calling + # {Google::Ads::DataManager.marketing_data_insights_service_available?}. + # + # ## About MarketingDataInsightsService + # + # Service to return insights on marketing data. + # + # This feature is only available to data partners. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. + # + def self.marketing_data_insights_service version: :v1, transport: :grpc, &block + require "google/ads/data_manager/#{version.to_s.downcase}" + + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + service_module = Google::Ads::DataManager.const_get(package_name).const_get(:MarketingDataInsightsService) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) + end + + ## + # Determines whether the MarketingDataInsightsService service is supported by the current client. + # If true, you can retrieve a client object by calling {Google::Ads::DataManager.marketing_data_insights_service}. + # If false, that method will raise an exception. This could happen if the given + # API version does not exist or does not support the MarketingDataInsightsService service, + # or if the versioned client gem needs an update to support the MarketingDataInsightsService service. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [boolean] Whether the service is available. + # + def self.marketing_data_insights_service_available? version: :v1, transport: :grpc + require "google/ads/data_manager/#{version.to_s.downcase}" + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + return false unless package_name + service_module = Google::Ads::DataManager.const_get package_name + return false unless service_module.const_defined? :MarketingDataInsightsService + service_module = service_module.const_get :MarketingDataInsightsService + if transport == :rest + return false unless service_module.const_defined? :Rest + service_module = service_module.const_get :Rest + end + service_module.const_defined? :Client + rescue ::LoadError + false + end + + ## + # Create a new client object for PartnerLinkService. + # + # By default, this returns an instance of + # [Google::Ads::DataManager::V1::PartnerLinkService::Client](https://rubydoc.info/gems/google-ads-data_manager-v1/Google/Ads/DataManager/V1/PartnerLinkService/Client) + # for a gRPC client for version V1 of the API. + # However, you can specify a different API version by passing it in the + # `version` parameter. If the PartnerLinkService 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. + # + # Raises an exception if the currently installed versioned client gem for the + # given API version does not support the given transport of the PartnerLinkService service. + # You can determine whether the method will succeed by calling + # {Google::Ads::DataManager.partner_link_service_available?}. + # + # ## About PartnerLinkService + # + # Service for managing partner links. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. + # + def self.partner_link_service version: :v1, transport: :grpc, &block + require "google/ads/data_manager/#{version.to_s.downcase}" + + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + service_module = Google::Ads::DataManager.const_get(package_name).const_get(:PartnerLinkService) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) + end + + ## + # Determines whether the PartnerLinkService service is supported by the current client. + # If true, you can retrieve a client object by calling {Google::Ads::DataManager.partner_link_service}. + # If false, that method will raise an exception. This could happen if the given + # API version does not exist or does not support the PartnerLinkService service, + # or if the versioned client gem needs an update to support the PartnerLinkService service. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [boolean] Whether the service is available. + # + def self.partner_link_service_available? version: :v1, transport: :grpc + require "google/ads/data_manager/#{version.to_s.downcase}" + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + return false unless package_name + service_module = Google::Ads::DataManager.const_get package_name + return false unless service_module.const_defined? :PartnerLinkService + service_module = service_module.const_get :PartnerLinkService + if transport == :rest + return false unless service_module.const_defined? :Rest + service_module = service_module.const_get :Rest + end + service_module.const_defined? :Client + rescue ::LoadError + false + end + + ## + # Create a new client object for UserListDirectLicenseService. + # + # By default, this returns an instance of + # [Google::Ads::DataManager::V1::UserListDirectLicenseService::Client](https://rubydoc.info/gems/google-ads-data_manager-v1/Google/Ads/DataManager/V1/UserListDirectLicenseService/Client) + # for a gRPC client for version V1 of the API. + # However, you can specify a different API version by passing it in the + # `version` parameter. If the UserListDirectLicenseService 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. + # + # Raises an exception if the currently installed versioned client gem for the + # given API version does not support the given transport of the UserListDirectLicenseService service. + # You can determine whether the method will succeed by calling + # {Google::Ads::DataManager.user_list_direct_license_service_available?}. + # + # ## About UserListDirectLicenseService + # + # Service for managing user list direct licenses. Delete is not a supported + # operation for UserListDirectLicenses. Callers should update the + # license status to DISABLED to instead to deactivate a license. + # + # This feature is only available to data partners. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. + # + def self.user_list_direct_license_service version: :v1, transport: :grpc, &block + require "google/ads/data_manager/#{version.to_s.downcase}" + + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + service_module = Google::Ads::DataManager.const_get(package_name).const_get(:UserListDirectLicenseService) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) + end + + ## + # Determines whether the UserListDirectLicenseService service is supported by the current client. + # If true, you can retrieve a client object by calling {Google::Ads::DataManager.user_list_direct_license_service}. + # If false, that method will raise an exception. This could happen if the given + # API version does not exist or does not support the UserListDirectLicenseService service, + # or if the versioned client gem needs an update to support the UserListDirectLicenseService service. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [boolean] Whether the service is available. + # + def self.user_list_direct_license_service_available? version: :v1, transport: :grpc + require "google/ads/data_manager/#{version.to_s.downcase}" + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + return false unless package_name + service_module = Google::Ads::DataManager.const_get package_name + return false unless service_module.const_defined? :UserListDirectLicenseService + service_module = service_module.const_get :UserListDirectLicenseService + if transport == :rest + return false unless service_module.const_defined? :Rest + service_module = service_module.const_get :Rest + end + service_module.const_defined? :Client + rescue ::LoadError + false + end + + ## + # Create a new client object for UserListGlobalLicenseService. + # + # By default, this returns an instance of + # [Google::Ads::DataManager::V1::UserListGlobalLicenseService::Client](https://rubydoc.info/gems/google-ads-data_manager-v1/Google/Ads/DataManager/V1/UserListGlobalLicenseService/Client) + # for a gRPC client for version V1 of the API. + # However, you can specify a different API version by passing it in the + # `version` parameter. If the UserListGlobalLicenseService 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. + # + # Raises an exception if the currently installed versioned client gem for the + # given API version does not support the given transport of the UserListGlobalLicenseService service. + # You can determine whether the method will succeed by calling + # {Google::Ads::DataManager.user_list_global_license_service_available?}. + # + # ## About UserListGlobalLicenseService + # + # Service for managing user list global licenses. Delete is not a supported + # operation for UserListGlobalLicenses. Callers should update the + # license status to DISABLED to instead to deactivate a license. + # + # This feature is only available to data partners. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. + # + def self.user_list_global_license_service version: :v1, transport: :grpc, &block + require "google/ads/data_manager/#{version.to_s.downcase}" + + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + service_module = Google::Ads::DataManager.const_get(package_name).const_get(:UserListGlobalLicenseService) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) + end + + ## + # Determines whether the UserListGlobalLicenseService service is supported by the current client. + # If true, you can retrieve a client object by calling {Google::Ads::DataManager.user_list_global_license_service}. + # If false, that method will raise an exception. This could happen if the given + # API version does not exist or does not support the UserListGlobalLicenseService service, + # or if the versioned client gem needs an update to support the UserListGlobalLicenseService service. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [boolean] Whether the service is available. + # + def self.user_list_global_license_service_available? version: :v1, transport: :grpc + require "google/ads/data_manager/#{version.to_s.downcase}" + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + return false unless package_name + service_module = Google::Ads::DataManager.const_get package_name + return false unless service_module.const_defined? :UserListGlobalLicenseService + service_module = service_module.const_get :UserListGlobalLicenseService + if transport == :rest + return false unless service_module.const_defined? :Rest + service_module = service_module.const_get :Rest + end + service_module.const_defined? :Client + rescue ::LoadError + false + end + + ## + # Create a new client object for UserListService. + # + # By default, this returns an instance of + # [Google::Ads::DataManager::V1::UserListService::Client](https://rubydoc.info/gems/google-ads-data_manager-v1/Google/Ads/DataManager/V1/UserListService/Client) + # for a gRPC client for version V1 of the API. + # However, you can specify a different API version by passing it in the + # `version` parameter. If the UserListService 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. + # + # Raises an exception if the currently installed versioned client gem for the + # given API version does not support the given transport of the UserListService service. + # You can determine whether the method will succeed by calling + # {Google::Ads::DataManager.user_list_service_available?}. + # + # ## About UserListService + # + # Service for managing UserList resources. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [::Object] A client object for the specified version. + # + def self.user_list_service version: :v1, transport: :grpc, &block + require "google/ads/data_manager/#{version.to_s.downcase}" + + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + service_module = Google::Ads::DataManager.const_get(package_name).const_get(:UserListService) + service_module = service_module.const_get(:Rest) if transport == :rest + service_module.const_get(:Client).new(&block) + end + + ## + # Determines whether the UserListService service is supported by the current client. + # If true, you can retrieve a client object by calling {Google::Ads::DataManager.user_list_service}. + # If false, that method will raise an exception. This could happen if the given + # API version does not exist or does not support the UserListService service, + # or if the versioned client gem needs an update to support the UserListService service. + # + # @param version [::String, ::Symbol] The API version to connect to. Optional. + # Defaults to `:v1`. + # @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`. + # @return [boolean] Whether the service is available. + # + def self.user_list_service_available? version: :v1, transport: :grpc + require "google/ads/data_manager/#{version.to_s.downcase}" + package_name = Google::Ads::DataManager + .constants + .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") } + .first + return false unless package_name + service_module = Google::Ads::DataManager.const_get package_name + return false unless service_module.const_defined? :UserListService + service_module = service_module.const_get :UserListService + if transport == :rest + return false unless service_module.const_defined? :Rest + service_module = service_module.const_get :Rest + end + service_module.const_defined? :Client + rescue ::LoadError + false + end end end end diff --git a/google-ads-data_manager/test/google/ads/data_manager/client_test.rb b/google-ads-data_manager/test/google/ads/data_manager/client_test.rb index ba937887aa5b..a0fea0cfb4b1 100644 --- a/google-ads-data_manager/test/google/ads/data_manager/client_test.rb +++ b/google-ads-data_manager/test/google/ads/data_manager/client_test.rb @@ -61,4 +61,109 @@ def test_ingestion_service_rest assert_kind_of Google::Ads::DataManager::V1::IngestionService::Rest::Client, client end end + + def test_marketing_data_insights_service_grpc + skip unless Google::Ads::DataManager.marketing_data_insights_service_available? transport: :grpc + Gapic::ServiceStub.stub :new, DummyStub.new do + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + client = Google::Ads::DataManager.marketing_data_insights_service transport: :grpc do |config| + config.credentials = grpc_channel + end + assert_kind_of Google::Ads::DataManager::V1::MarketingDataInsightsService::Client, client + end + end + + def test_marketing_data_insights_service_rest + skip unless Google::Ads::DataManager.marketing_data_insights_service_available? transport: :rest + Gapic::Rest::ClientStub.stub :new, DummyStub.new do + client = Google::Ads::DataManager.marketing_data_insights_service transport: :rest do |config| + config.credentials = :dummy_credentials + end + assert_kind_of Google::Ads::DataManager::V1::MarketingDataInsightsService::Rest::Client, client + end + end + + def test_partner_link_service_grpc + skip unless Google::Ads::DataManager.partner_link_service_available? transport: :grpc + Gapic::ServiceStub.stub :new, DummyStub.new do + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + client = Google::Ads::DataManager.partner_link_service transport: :grpc do |config| + config.credentials = grpc_channel + end + assert_kind_of Google::Ads::DataManager::V1::PartnerLinkService::Client, client + end + end + + def test_partner_link_service_rest + skip unless Google::Ads::DataManager.partner_link_service_available? transport: :rest + Gapic::Rest::ClientStub.stub :new, DummyStub.new do + client = Google::Ads::DataManager.partner_link_service transport: :rest do |config| + config.credentials = :dummy_credentials + end + assert_kind_of Google::Ads::DataManager::V1::PartnerLinkService::Rest::Client, client + end + end + + def test_user_list_direct_license_service_grpc + skip unless Google::Ads::DataManager.user_list_direct_license_service_available? transport: :grpc + Gapic::ServiceStub.stub :new, DummyStub.new do + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + client = Google::Ads::DataManager.user_list_direct_license_service transport: :grpc do |config| + config.credentials = grpc_channel + end + assert_kind_of Google::Ads::DataManager::V1::UserListDirectLicenseService::Client, client + end + end + + def test_user_list_direct_license_service_rest + skip unless Google::Ads::DataManager.user_list_direct_license_service_available? transport: :rest + Gapic::Rest::ClientStub.stub :new, DummyStub.new do + client = Google::Ads::DataManager.user_list_direct_license_service transport: :rest do |config| + config.credentials = :dummy_credentials + end + assert_kind_of Google::Ads::DataManager::V1::UserListDirectLicenseService::Rest::Client, client + end + end + + def test_user_list_global_license_service_grpc + skip unless Google::Ads::DataManager.user_list_global_license_service_available? transport: :grpc + Gapic::ServiceStub.stub :new, DummyStub.new do + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + client = Google::Ads::DataManager.user_list_global_license_service transport: :grpc do |config| + config.credentials = grpc_channel + end + assert_kind_of Google::Ads::DataManager::V1::UserListGlobalLicenseService::Client, client + end + end + + def test_user_list_global_license_service_rest + skip unless Google::Ads::DataManager.user_list_global_license_service_available? transport: :rest + Gapic::Rest::ClientStub.stub :new, DummyStub.new do + client = Google::Ads::DataManager.user_list_global_license_service transport: :rest do |config| + config.credentials = :dummy_credentials + end + assert_kind_of Google::Ads::DataManager::V1::UserListGlobalLicenseService::Rest::Client, client + end + end + + def test_user_list_service_grpc + skip unless Google::Ads::DataManager.user_list_service_available? transport: :grpc + Gapic::ServiceStub.stub :new, DummyStub.new do + grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure + client = Google::Ads::DataManager.user_list_service transport: :grpc do |config| + config.credentials = grpc_channel + end + assert_kind_of Google::Ads::DataManager::V1::UserListService::Client, client + end + end + + def test_user_list_service_rest + skip unless Google::Ads::DataManager.user_list_service_available? transport: :rest + Gapic::Rest::ClientStub.stub :new, DummyStub.new do + client = Google::Ads::DataManager.user_list_service transport: :rest do |config| + config.credentials = :dummy_credentials + end + assert_kind_of Google::Ads::DataManager::V1::UserListService::Rest::Client, client + end + end end