public void Run(AdWordsUser user, long adGroupId)
{
// Get the AdGroupService.
AdGroupService adGroupService =
(AdGroupService) user.GetService(AdWordsService.v201306.AdGroupService);
// Create the ad group.
AdGroup adGroup = new AdGroup();
adGroup.status = AdGroupStatus.PAUSED;
adGroup.id = adGroupId;
// Create the operation.
AdGroupOperation operation = new AdGroupOperation();
operation.@operator = Operator.SET;
operation.operand = adGroup;
try {
// Update the ad group.
AdGroupReturnValue retVal = adGroupService.mutate(new AdGroupOperation[] {operation});
// Display the results.
if (retVal != null && retVal.value != null && retVal.value.Length > 0) {
AdGroup pausedAdGroup = retVal.value[0];
Console.WriteLine("Ad group with id = '{0}' was successfully updated.",
pausedAdGroup.id);
} else {
Console.WriteLine("No ad groups were updated.");
}
} catch (Exception ex) {
throw new System.ApplicationException("Failed to update ad group.", ex);
}
}