lib/google/ads/google_ads/factories/v1/operations.rb in google-ads-googleads-2.1.1 vs lib/google/ads/google_ads/factories/v1/operations.rb in google-ads-googleads-2.2.0

- old
+ new

@@ -154,10 +154,26 @@ def self.campaign_criterion require "google/ads/google_ads/v1/services/campaign_criterion_service_pb.rb" Google::Ads::GoogleAds::V1::Services::CampaignCriterionOperation.new end + # Create a new CampaignDraftOperation + # + # @return [Google::Ads::GoogleAds::V1::Services::CampaignDraftOperation] the operation + def self.campaign_draft + require "google/ads/google_ads/v1/services/campaign_draft_service_pb.rb" + Google::Ads::GoogleAds::V1::Services::CampaignDraftOperation.new + end + + # Create a new CampaignExperimentOperation + # + # @return [Google::Ads::GoogleAds::V1::Services::CampaignExperimentOperation] the operation + def self.campaign_experiment + require "google/ads/google_ads/v1/services/campaign_experiment_service_pb.rb" + Google::Ads::GoogleAds::V1::Services::CampaignExperimentOperation.new + end + # Create a new CampaignExtensionSettingOperation # # @return [Google::Ads::GoogleAds::V1::Services::CampaignExtensionSettingOperation] the operation def self.campaign_extension_setting require "google/ads/google_ads/v1/services/campaign_extension_setting_service_pb.rb" @@ -793,10 +809,60 @@ end op end + # A convenience method for creating an CampaignDraftOperation instance with + # its "create" field prepopulated with an CampaignDraft instance. + # + # @overload campaign_draft + # creates an operation instance, yielding a newly fabricated CampaignDraft + # which can be used for setting attributes on the newly created resource + # @overload campaign_draft(res) + # creates an operation instance, with the resource to be created + # set to the passed value (res) + # @param res [Google::Ads::GoogleAds::V1::Resources::CampaignDraft] + # a resource instance to be used for creation in this operation. + # + # @return [Google::Ads::GoogleAds::V1::Services::CampaignDraftOperation] instance that will create the resource + def self.campaign_draft(res = nil, &blk) + require "google/ads/google_ads/v1/services/campaign_draft_service_pb.rb" + op = Google::Ads::GoogleAds::V1::Services::CampaignDraftOperation.new + if !res.nil? + op["create"] = res + elsif !blk.nil? + op["create"] = Factories::V1::Resources.campaign_draft(&blk) + end + + op + end + + # A convenience method for creating an CampaignExperimentOperation instance with + # its "create" field prepopulated with an CampaignExperiment instance. + # + # @overload campaign_experiment + # creates an operation instance, yielding a newly fabricated CampaignExperiment + # which can be used for setting attributes on the newly created resource + # @overload campaign_experiment(res) + # creates an operation instance, with the resource to be created + # set to the passed value (res) + # @param res [Google::Ads::GoogleAds::V1::Resources::CampaignExperiment] + # a resource instance to be used for creation in this operation. + # + # @return [Google::Ads::GoogleAds::V1::Services::CampaignExperimentOperation] instance that will create the resource + def self.campaign_experiment(res = nil, &blk) + require "google/ads/google_ads/v1/services/campaign_experiment_service_pb.rb" + op = Google::Ads::GoogleAds::V1::Services::CampaignExperimentOperation.new + if !res.nil? + op["create"] = res + elsif !blk.nil? + op["create"] = Factories::V1::Resources.campaign_experiment(&blk) + end + + op + end + # A convenience method for creating an CampaignExtensionSettingOperation instance with # its "create" field prepopulated with an CampaignExtensionSetting instance. # # @overload campaign_extension_setting # creates an operation instance, yielding a newly fabricated CampaignExtensionSetting @@ -1997,10 +2063,49 @@ op["update_mask"] = Google::Ads::GoogleAds::FieldMaskUtil.with(res, &blk) op["update"] = res op end + # A convenience method for creating an CampaignDraftOperation instance with + # its "update" field prepopulated with an CampaignDraft instance, and + # its "update_mask" field populated as needed to send the updates to the API. + # + # @overload #campaign_draft(path, &blk) + # @param path [String] a resource path for the resource to update + # @yield [Google::Ads::GoogleAds::V1::Resources::CampaignDraft] a new instance of the resource for this update operation, on + # which fields can be set to update + # + # @overload #campaign_draft(resource, &blk) + # @param resource [Google::Ads::GoogleAds::V1::Resources::CampaignDraft] a resource instance to update + # @yield the passed block is called and updates against `resource` are recordered in the update mask + # @return [Google::Ads::GoogleAds::V1::Services::CampaignDraftOperation] the operation instance to update the resource + def self.campaign_draft(resource_or_path, &blk) + require "google/ads/google_ads/v1/services/campaign_draft_service_pb.rb" + res = case resource_or_path + when Google::Ads::GoogleAds::V1::Resources::CampaignDraft + resource_or_path + # got a resource path + when String + obj = Google::Ads::GoogleAds::V1::Resources::CampaignDraft.new + obj.resource_name = resource_or_path + obj + else + unless Google::Ads::GoogleAds::V1::Resources::CampaignDraft === res + raise ArgumentError.new( + "Called #{__method__} with instance of wrong type:"\ + " #{res.class} want #{operation.update_class}"\ + " or String representing resource name" + ) + end + end + + op = Google::Ads::GoogleAds::V1::Services::CampaignDraftOperation.new + op["update_mask"] = Google::Ads::GoogleAds::FieldMaskUtil.with(res, &blk) + op["update"] = res + op + end + # A convenience method for creating an CampaignExtensionSettingOperation instance with # its "update" field prepopulated with an CampaignExtensionSetting instance, and # its "update_mask" field populated as needed to send the updates to the API. # # @overload #campaign_extension_setting(path, &blk) @@ -3238,9 +3343,29 @@ # its "remove" field preopulated with a resource path corresponding to the resource to be removed. # # @param path [String] the resource name of the resource to delete. def self.campaign_criterion(path) op = Google::Ads::GoogleAds::V1::Services::CampaignCriterionOperation.new + op["remove"] = path + op + end + + # A convenience method for creationg an CampaignDraftOperation instance with + # its "remove" field preopulated with a resource path corresponding to the resource to be removed. + # + # @param path [String] the resource name of the resource to delete. + def self.campaign_draft(path) + op = Google::Ads::GoogleAds::V1::Services::CampaignDraftOperation.new + op["remove"] = path + op + end + + # A convenience method for creationg an CampaignExperimentOperation instance with + # its "remove" field preopulated with a resource path corresponding to the resource to be removed. + # + # @param path [String] the resource name of the resource to delete. + def self.campaign_experiment(path) + op = Google::Ads::GoogleAds::V1::Services::CampaignExperimentOperation.new op["remove"] = path op end # A convenience method for creationg an CampaignExtensionSettingOperation instance with