Esempio n. 1
0
        /// <summary>
        /// Creates an ad group for a given campaign
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="campaignResourceName">Resource name of the campaign to add the ad group
        /// to.</param>
        /// <returns>The resource name of the newly created ad group.</returns>
        private string CreateAdGroup(GoogleAdsClient client, long customerId,
                                     string campaignResourceName)
        {
            // Get the AdGroupService.
            AdGroupServiceClient adGroupService = client.GetService(Services.V4.AdGroupService);

            // Creates an ad group.
            // Note that the ad group type must not be set.
            // Since the advertising_channel_sub_type is APP_CAMPAIGN,
            //   1. you cannot override bid settings at the ad group level.
            //   2. you cannot add ad group criteria.
            AdGroup adGroup = new AdGroup()
            {
                Name     = $"Earth to Mars Cruises #{ExampleUtilities.GetRandomString()}",
                Status   = AdGroupStatus.Enabled,
                Campaign = campaignResourceName
            };

            // Creates an ad group operation.
            // Create the operation.
            AdGroupOperation operation = new AdGroupOperation()
            {
                Create = adGroup
            };

            // Submits the ad group operation to add the ad group and prints the results.
            MutateAdGroupsResponse response =
                adGroupService.MutateAdGroups(customerId.ToString(), new[] { operation });

            // Prints and returns the ad group resource name.
            string adGroupResourceName = response.Results[0].ResourceName;

            Console.WriteLine($"Created an ad group with resource name '{adGroupResourceName}'.");
            return(adGroupResourceName);
        }
        public async stt::Task MutateAdGroupsAsync()
        {
            moq::Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new moq::Mock <AdGroupService.AdGroupServiceClient>(moq::MockBehavior.Strict);
            MutateAdGroupsRequest request = new MutateAdGroupsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new AdGroupOperation(),
                },
            };
            MutateAdGroupsResponse expectedResponse = new MutateAdGroupsResponse
            {
                Results =
                {
                    new MutateAdGroupResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateAdGroupsAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <MutateAdGroupsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            AdGroupServiceClient   client = new AdGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateAdGroupsResponse responseCallSettings = await client.MutateAdGroupsAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            MutateAdGroupsResponse responseCancellationToken = await client.MutateAdGroupsAsync(request.CustomerId, request.Operations, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="adGroupId">ID of the ad group to remove.</param>
        public void Run(GoogleAdsClient client, long customerId, long adGroupId)
        {
            // Get the AdGroupService.
            AdGroupServiceClient service = client.GetService(Services.V10.AdGroupService);

            // Construct an operation that will remove the ad group with the specified
            // resource name.
            AdGroupOperation operation = new AdGroupOperation
            {
                Remove = ResourceNames.AdGroup(customerId, adGroupId)
            };

            try
            {
                // Send the operation in a mutate request.
                MutateAdGroupsResponse response = service.MutateAdGroups(customerId.ToString(),
                                                                         new AdGroupOperation[] { operation });

                // Display the result.
                foreach (MutateAdGroupResult result in response.Results)
                {
                    Console.WriteLine($"Removed ad group with resourceName: " +
                                      $"{result.ResourceName}.");
                }
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the hotel ad group.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="campaignResourceName">The resource name of campaign that a new ad group
        /// will belong to.</param>
        /// <returns>The resource name of the newly created ad group.</returns>
        private static string AddHotelAdGroup(GoogleAdsClient client, long customerId,
                                              string campaignResourceName)
        {
            // Get the AdGroupService.
            AdGroupServiceClient service = client.GetService(Services.V4.AdGroupService);

            // Create an ad group.
            AdGroup adGroup = new AdGroup()
            {
                Name = "Earth to Mars Cruise #" + ExampleUtilities.GetRandomString(),

                // Sets the campaign.
                Campaign = campaignResourceName,

                // Optional: Sets the ad group type to HOTEL_ADS.
                // This cannot be set to other types.
                Type = AdGroupType.HotelAds,

                CpcBidMicros = 10000000,
                Status       = AdGroupStatus.Enabled
            };

            // Create an ad group operation.
            AdGroupOperation adGroupOperation = new AdGroupOperation()
            {
                Create = adGroup
            };

            // Issue a mutate request to add an ad group.
            MutateAdGroupsResponse response = service.MutateAdGroups(customerId.ToString(),
                                                                     new AdGroupOperation[] { adGroupOperation });

            return(response.Results[0].ResourceName);
        }
        /// <summary>Adds an ad group.</summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="campaignResourceName">The campaign resource name.</param>
        /// <returns>The ad group resource name.</returns>
        private static string AddAdGroup(GoogleAdsClient client, long customerId,
                                         string campaignResourceName)
        {
            // Get the AdGroupService.
            AdGroupServiceClient adGroupService = client.GetService(Services.V4.AdGroupService);

            // Create the ad group.
            AdGroup adGroup = new AdGroup()
            {
                Name                = "Earth to Mars Cruises #" + ExampleUtilities.GetRandomString(),
                Campaign            = campaignResourceName,
                Type                = AdGroupType.SearchDynamicAds,
                Status              = AdGroupStatus.Paused,
                TrackingUrlTemplate = "http://tracker.examples.com/traveltracker/{escapedlpurl}",
                CpcBidMicros        = 50_000
            };

            // Create the operation.
            AdGroupOperation operation = new AdGroupOperation()
            {
                Create = adGroup
            };

            // Add the ad group.
            MutateAdGroupsResponse response =
                adGroupService.MutateAdGroups(customerId.ToString(),
                                              new AdGroupOperation[] { operation });

            // Display the results.
            string adGroupResourceName = response.Results[0].ResourceName;

            Console.WriteLine($"Added ad group with resource name '{adGroupResourceName}'.");

            return(adGroupResourceName);
        }
        public void MutateAdGroups()
        {
            moq::Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new moq::Mock <AdGroupService.AdGroupServiceClient>(moq::MockBehavior.Strict);
            MutateAdGroupsRequest request = new MutateAdGroupsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new AdGroupOperation(),
                },
            };
            MutateAdGroupsResponse expectedResponse = new MutateAdGroupsResponse
            {
                Results =
                {
                    new MutateAdGroupResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateAdGroups(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AdGroupServiceClient   client   = new AdGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateAdGroupsResponse response = client.MutateAdGroups(request.CustomerId, request.Operations);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 7
0
        /// <summary>
        /// Creates the ad group.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="campaignResourceName">The campaign resource name.</param>
        /// <returns>The resource name of the newly created ad group.</returns>
        private string CreateAdGroup(GoogleAdsClient client, long customerId,
                                     string campaignResourceName)
        {
            // Get the AdGroupService.
            AdGroupServiceClient adGroupService = client.GetService(Services.V3.AdGroupService);

            // Create the ad group.
            AdGroup adGroup = new AdGroup()
            {
                Name     = $"Earth to Mars Cruises #{ExampleUtilities.GetRandomString()}",
                Status   = AdGroupStatusEnum.Types.AdGroupStatus.Enabled,
                Campaign = campaignResourceName,
            };

            // Create the operation.
            AdGroupOperation operation = new AdGroupOperation()
            {
                Create = adGroup
            };

            // Create the ad groups.
            MutateAdGroupsResponse response = adGroupService.MutateAdGroups(
                customerId.ToString(), new[] { operation });

            string adGroupResourceName = response.Results.First().ResourceName;

            // Print out some information about the added ad group.
            Console.WriteLine($"Added ad group with resource name = '{adGroupResourceName}'.");

            return(adGroupResourceName);
        }
        /// <summary>
        /// Displays the result from the mutate operation.
        /// </summary>
        /// <param name="response">The mutate response from the Google Ads API server..</param>
        private void PrintResults(MutateAdGroupsResponse response)
        {
            // Finds the failed operations by looping through the results.
            int operationIndex = 0;

            foreach (MutateAdGroupResult result in response.Results)
            {
                // This represents the result of a failed operation.
                if (result.IsEmpty())
                {
                    List <GoogleAdsError> errors =
                        response.PartialFailure.GetErrorsByOperationIndex(operationIndex);
                    foreach (GoogleAdsError error in errors)
                    {
                        Console.WriteLine($"Operation {operationIndex} failed with " +
                                          $"error: {error}.");
                    }
                }
                else
                {
                    Console.WriteLine($"Operation {operationIndex} succeeded.",
                                      operationIndex);
                }
                operationIndex++;
            }
        }
        public void MutateAdGroupsRequestObject()
        {
            moq::Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new moq::Mock <AdGroupService.AdGroupServiceClient>(moq::MockBehavior.Strict);
            MutateAdGroupsRequest request = new MutateAdGroupsRequest
            {
                CustomerId = "customer_id3b3724cb",
                Operations =
                {
                    new AdGroupOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = true,
                ResponseContentType = gagve::ResponseContentTypeEnum.Types.ResponseContentType.ResourceNameOnly,
            };
            MutateAdGroupsResponse expectedResponse = new MutateAdGroupsResponse
            {
                Results =
                {
                    new MutateAdGroupResult(),
                },
                PartialFailureError = new gr::Status(),
            };

            mockGrpcClient.Setup(x => x.MutateAdGroups(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AdGroupServiceClient   client   = new AdGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateAdGroupsResponse response = client.MutateAdGroups(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>
        /// Updates the given TargetingSetting of an ad group.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID.</param>
        /// <param name="adGroupId">The ad group ID for which to update the audience targeting
        ///     restriction.</param>
        /// <param name="targetingSetting">The updated targeting setting.</param>
        // [START update_audience_target_restriction_2]
        private void UpdateTargetingSetting(GoogleAdsClient client, long customerId, long
                                            adGroupId, TargetingSetting targetingSetting)
        {
            // Get the AdGroupService client.
            AdGroupServiceClient adGroupServiceClient =
                client.GetService(Services.V10.AdGroupService);

            // Create an ad group object with the updated targeting setting.
            AdGroup adGroup = new AdGroup
            {
                ResourceName     = ResourceNames.AdGroup(customerId, adGroupId),
                TargetingSetting = targetingSetting
            };

            // Construct an operation that will update the ad group, using the FieldMasks utility
            // to derive the update mask. This mask tells the Google Ads API which attributes of the
            // ad group you want to change.
            AdGroupOperation operation = new AdGroupOperation
            {
                Update     = adGroup,
                UpdateMask = FieldMasks.AllSetFieldsOf(adGroup)
            };

            // Send the operation in a mutate request.
            MutateAdGroupsResponse response =
                adGroupServiceClient.MutateAdGroups(customerId.ToString(), new[] { operation });

            // Print the resource name of the updated object.
            Console.WriteLine("Updated targeting setting of ad group with resource name " +
                              $"'{response.Results.First().ResourceName}'; set the AUDIENCE target restriction " +
                              "to 'Observation'.");
        }
Esempio n. 11
0
        /// <summary>
        /// Creates an ad group for the remarketing campaign.
        /// </summary>
        /// <param name="client">The Google Ads API client.</param>
        /// <param name="customerId">The client customer ID.</param>
        /// <param name="campaignResourceName">The campaign resource name.</param>
        /// <returns>The string resource name for the newly created ad group.</returns>
        private string CreateAdGroup(GoogleAdsClient client, long customerId,
                                     string campaignResourceName)
        {
            // Creates the ad group service client.
            AdGroupServiceClient adGroupServiceClient =
                client.GetService(Services.V6.AdGroupService);

            // Creates the ad group.
            AdGroup adGroup = new AdGroup()
            {
                Name     = "Dynamic remarketing ad group",
                Campaign = campaignResourceName,
                Status   = AdGroupStatus.Enabled
            };

            // Creates the ad group operation.
            AdGroupOperation operation = new AdGroupOperation()
            {
                Create = adGroup
            };

            // Adds the ad group.
            MutateAdGroupsResponse response = adGroupServiceClient.MutateAdGroups(
                customerId.ToString(), new[] { operation });

            string adGroupResourceName = response.Results.First().ResourceName;

            Console.WriteLine($"Created ad group with resource name '{adGroupResourceName}'.");
            return(adGroupResourceName);
        }
Esempio n. 12
0
        public void TestPartialFailureWithNoErrors()
        {
            MutateAdGroupsResponse failedResponse = new MutateAdGroupsResponse()
            {
                PartialFailureError = null
            };

            Assert.Null(failedResponse.PartialFailure);
        }
        /// <summary>
        /// Attempts to create 3 ad groups with partial failure enabled. One of the ad groups
        /// will succeed, while the other will fail.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The customer ID for which the call is made.</param>
        /// <param name="campaignId">ID of the campaign to which ad groups are added.</param>
        /// <returns>The mutate response from the Google Ads server.</returns>
        private static MutateAdGroupsResponse CreateAdGroups(GoogleAdsClient client,
                                                             long customerId, long campaignId)
        {
            // Get the AdGroupServiceClient.
            AdGroupServiceClient adGroupService = client.GetService(Services.V5.AdGroupService);

            string validAdGroupName = "Valid AdGroup: " + ExampleUtilities.GetRandomString();

            AdGroupOperation[] operations = new AdGroupOperation[]
            {
                // This operation will be successful, assuming the campaign specified in
                // campaignId parameter is correct.
                new AdGroupOperation()
                {
                    Create = new AdGroup()
                    {
                        Campaign = ResourceNames.Campaign(customerId, campaignId),
                        Name     = validAdGroupName
                    }
                },
                // This operation will fail since we are using campaign ID = 0, which results
                // in an invalid resource name.
                new AdGroupOperation()
                {
                    Create = new AdGroup()
                    {
                        Campaign = ResourceNames.Campaign(customerId, 0),
                        Name     = "Broken AdGroup: " + ExampleUtilities.GetRandomString()
                    },
                },
                // This operation will fail since the ad group is using the same name as the ad
                // group from the first operation. Duplicate ad group names are not allowed.
                new AdGroupOperation()
                {
                    Create = new AdGroup()
                    {
                        Campaign = ResourceNames.Campaign(customerId, campaignId),
                        Name     = validAdGroupName
                    }
                }
            };

            // Add the ad groups.
            MutateAdGroupsResponse response =
                adGroupService.MutateAdGroups(new MutateAdGroupsRequest()
            {
                CustomerId     = customerId.ToString(),
                Operations     = { operations },
                PartialFailure = true,
                ValidateOnly   = false
            });

            return(response);
        }
Esempio n. 14
0
        public void TestPartialFailureDeserialization()
        {
            GoogleAdsFailure failure = new GoogleAdsFailure();

            failure.Errors.Add(OPERATIONS_2_NAME);
            MutateAdGroupsResponse failedResponse = new MutateAdGroupsResponse()
            {
                PartialFailureError = GetStatus(failure)
            };

            Assert.True(failedResponse.PartialFailure.Equals(failure));
        }
 /// <summary>Snippet for MutateAdGroups</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAdGroups()
 {
     // Create client
     AdGroupServiceClient adGroupServiceClient = AdGroupServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     IEnumerable <AdGroupOperation> operations = new AdGroupOperation[]
     {
         new AdGroupOperation(),
     };
     // Make the request
     MutateAdGroupsResponse response = adGroupServiceClient.MutateAdGroups(customerId, operations);
 }
Esempio n. 16
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="campaignId">ID of the campaign to which ad groups are added.</param>
        public void Run(GoogleAdsClient client, long customerId, long campaignId)
        {
            // Get the AdGroupService.
            AdGroupServiceClient adGroupService = client.GetService(Services.V6.AdGroupService);

            List <AdGroupOperation> operations = new List <AdGroupOperation>();

            for (int i = 0; i < NUM_ADGROUPS_TO_CREATE; i++)
            {
                // Create the ad group.
                AdGroup adGroup = new AdGroup()
                {
                    Name     = $"Earth to Mars Cruises #{ExampleUtilities.GetRandomString()}",
                    Status   = AdGroupStatusEnum.Types.AdGroupStatus.Enabled,
                    Campaign = ResourceNames.Campaign(customerId, campaignId),

                    // Set the ad group bids.
                    CpcBidMicros = 10000000
                };

                // Create the operation.
                AdGroupOperation operation = new AdGroupOperation()
                {
                    Create = adGroup
                };
                operations.Add(operation);
            }

            try
            {
                // Create the ad groups.
                MutateAdGroupsResponse response = adGroupService.MutateAdGroups(
                    customerId.ToString(), operations);

                // Display the results.
                foreach (MutateAdGroupResult newAdGroup in response.Results)
                {
                    Console.WriteLine("Ad group with resource name '{0}' was created.",
                                      newAdGroup.ResourceName);
                }
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="adGroupId">Id of the ad group to be updated.</param>
        /// <param name="cpcBidMicroAmount">The CPC bid amount for the ad group in micros.</param>
        public void Run(GoogleAdsClient client, long customerId, long adGroupId,
                        long?cpcBidMicroAmount)
        {
            AdGroupServiceClient adGroupService = client.GetService(Services.V4.AdGroupService);

            // Create an ad group with the specified ID.
            AdGroup adGroup = new AdGroup();

            adGroup.ResourceName = ResourceNames.AdGroup(customerId, adGroupId);

            // Pause the ad group.
            adGroup.Status = AdGroupStatusEnum.Types.AdGroupStatus.Paused;

            // Update the CPC bid if specified.
            if (cpcBidMicroAmount != null)
            {
                adGroup.CpcBidMicros = cpcBidMicroAmount;
            }

            // Create the operation.
            AdGroupOperation operation = new AdGroupOperation()
            {
                Update     = adGroup,
                UpdateMask = FieldMasks.AllSetFieldsOf(adGroup)
            };

            try
            {
                // Update the ad group.
                MutateAdGroupsResponse retVal = adGroupService.MutateAdGroups(
                    customerId.ToString(), new AdGroupOperation[] { operation });

                // Display the results.
                MutateAdGroupResult adGroupResult = retVal.Results[0];

                Console.WriteLine($"Ad group with resource name '{adGroupResult.ResourceName}' " +
                                  "was updated.");
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
        /// <summary>
        /// Runs the code example.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The customer ID for which the call is made.</param>
        /// <param name="campaignId">ID of the campaign to which ad groups are added.</param>
        public void Run(GoogleAdsClient client, long customerId, long campaignId)
        {
            try
            {
                MutateAdGroupsResponse response = CreateAdGroups(client, customerId, campaignId);

                // Checks for existence of any partial failures in the response.
                if (CheckIfPartialFailureErrorExists(response))
                {
                    Console.WriteLine("Partial failures occurred. Details will be shown below.");
                }
                else
                {
                    Console.WriteLine("All operations completed successfully. No partial " +
                                      "failures to show.");
                    return;
                }

                // Finds the failed operations by looping through the results.
                PrintResults(response);

                // Display the results.
                if (response.PartialFailureError != null)
                {
                    Console.WriteLine("Partial failures occurred. Details will be shown below.");
                }
                else
                {
                    Console.WriteLine("All operations completed successfully. No partial " +
                                      "failures to show.");
                    return;
                }

                // Finds the failed operations by looping through the results.
                PrintResults(response);
            }
            catch (GoogleAdsException e)
            {
                Console.WriteLine("Failure:");
                Console.WriteLine($"Message: {e.Message}");
                Console.WriteLine($"Failure: {e.Failure}");
                Console.WriteLine($"Request ID: {e.RequestId}");
                throw;
            }
        }
        public void MutateAdGroups2()
        {
            Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new Mock <AdGroupService.AdGroupServiceClient>(MockBehavior.Strict);
            MutateAdGroupsRequest request = new MutateAdGroupsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateAdGroupsResponse expectedResponse = new MutateAdGroupsResponse();

            mockGrpcClient.Setup(x => x.MutateAdGroups(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            AdGroupServiceClient   client   = new AdGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateAdGroupsResponse response = client.MutateAdGroups(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task MutateAdGroupsAsync2()
        {
            Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new Mock <AdGroupService.AdGroupServiceClient>(MockBehavior.Strict);
            MutateAdGroupsRequest request = new MutateAdGroupsRequest
            {
                CustomerId = "customerId-1772061412",
                Operations = { },
            };
            MutateAdGroupsResponse expectedResponse = new MutateAdGroupsResponse();

            mockGrpcClient.Setup(x => x.MutateAdGroupsAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateAdGroupsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            AdGroupServiceClient   client   = new AdGroupServiceClientImpl(mockGrpcClient.Object, null);
            MutateAdGroupsResponse response = await client.MutateAdGroupsAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for MutateAdGroupsAsync</summary>
        public async Task MutateAdGroupsAsync()
        {
            // Snippet: MutateAdGroupsAsync(string, IEnumerable<AdGroupOperation>, CallSettings)
            // Additional: MutateAdGroupsAsync(string, IEnumerable<AdGroupOperation>, CancellationToken)
            // Create client
            AdGroupServiceClient adGroupServiceClient = await AdGroupServiceClient.CreateAsync();

            // Initialize request argument(s)
            string customerId = "";
            IEnumerable <AdGroupOperation> operations = new AdGroupOperation[]
            {
                new AdGroupOperation(),
            };
            // Make the request
            MutateAdGroupsResponse response = await adGroupServiceClient.MutateAdGroupsAsync(customerId, operations);

            // End snippet
        }
Esempio n. 22
0
 /// <summary>Snippet for MutateAdGroups</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateAdGroupsRequestObject()
 {
     // Create client
     AdGroupServiceClient adGroupServiceClient = AdGroupServiceClient.Create();
     // Initialize request argument(s)
     MutateAdGroupsRequest request = new MutateAdGroupsRequest
     {
         CustomerId = "",
         Operations =
         {
             new AdGroupOperation(),
         },
         PartialFailure = false,
         ValidateOnly   = false,
     };
     // Make the request
     MutateAdGroupsResponse response = adGroupServiceClient.MutateAdGroups(request);
 }
Esempio n. 23
0
        /// <summary>Snippet for MutateAdGroupsAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task MutateAdGroupsRequestObjectAsync()
        {
            // Create client
            AdGroupServiceClient adGroupServiceClient = await AdGroupServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateAdGroupsRequest request = new MutateAdGroupsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new AdGroupOperation(),
                },
                PartialFailure      = false,
                ValidateOnly        = false,
                ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
            };
            // Make the request
            MutateAdGroupsResponse response = await adGroupServiceClient.MutateAdGroupsAsync(request);
        }
 /// <summary>Snippet for MutateAdGroups</summary>
 public void MutateAdGroupsRequestObject()
 {
     // Snippet: MutateAdGroups(MutateAdGroupsRequest, CallSettings)
     // Create client
     AdGroupServiceClient adGroupServiceClient = AdGroupServiceClient.Create();
     // Initialize request argument(s)
     MutateAdGroupsRequest request = new MutateAdGroupsRequest
     {
         CustomerId = "",
         Operations =
         {
             new AdGroupOperation(),
         },
         PartialFailure      = false,
         ValidateOnly        = false,
         ResponseContentType = ResponseContentTypeEnum.Types.ResponseContentType.Unspecified,
     };
     // Make the request
     MutateAdGroupsResponse response = adGroupServiceClient.MutateAdGroups(request);
     // End snippet
 }
Esempio n. 25
0
        /// <summary>Snippet for MutateAdGroupsAsync</summary>
        public async Task MutateAdGroupsRequestObjectAsync()
        {
            // Snippet: MutateAdGroupsAsync(MutateAdGroupsRequest, CallSettings)
            // Additional: MutateAdGroupsAsync(MutateAdGroupsRequest, CancellationToken)
            // Create client
            AdGroupServiceClient adGroupServiceClient = await AdGroupServiceClient.CreateAsync();

            // Initialize request argument(s)
            MutateAdGroupsRequest request = new MutateAdGroupsRequest
            {
                CustomerId = "",
                Operations =
                {
                    new AdGroupOperation(),
                },
                PartialFailure = false,
                ValidateOnly   = false,
            };
            // Make the request
            MutateAdGroupsResponse response = await adGroupServiceClient.MutateAdGroupsAsync(request);

            // End snippet
        }
Esempio n. 26
0
        public async Task MutateAdGroupsAsync()
        {
            Mock <AdGroupService.AdGroupServiceClient> mockGrpcClient = new Mock <AdGroupService.AdGroupServiceClient>(MockBehavior.Strict);
            MutateAdGroupsRequest expectedRequest = new MutateAdGroupsRequest
            {
                CustomerId     = "customerId-1772061412",
                Operations     = { },
                PartialFailure = true,
                ValidateOnly   = false,
            };
            MutateAdGroupsResponse expectedResponse = new MutateAdGroupsResponse();

            mockGrpcClient.Setup(x => x.MutateAdGroupsAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <MutateAdGroupsResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            AdGroupServiceClient client = new AdGroupServiceClientImpl(mockGrpcClient.Object, null);
            string customerId           = "customerId-1772061412";
            IEnumerable <AdGroupOperation> operations = new List <AdGroupOperation>();
            bool partialFailure             = true;
            bool validateOnly               = false;
            MutateAdGroupsResponse response = await client.MutateAdGroupsAsync(customerId, operations, partialFailure, validateOnly);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>
 /// Inspects a response to check for presence of partial failure errors.
 /// </summary>
 /// <param name="response">The response.</param>
 /// <returns>True if there are partial failures, false otherwise.</returns>
 private static bool CheckIfPartialFailureErrorExists(MutateAdGroupsResponse response)
 {
     return(response.PartialFailureError == null);
 }