コード例 #1
0
        /// <summary>
        /// Modifies the user access role to a specified value.
        /// </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="userId">ID of the user whose access role is modified.</param>
        /// <param name="accessRole">The updated access role.</param>
        private void ModifyUserAccess(GoogleAdsClient client, long customerId, long userId,
                                      AccessRole accessRole)
        {
            // Get the CustomerUserAccessService.
            CustomerUserAccessServiceClient userAccessService = client.GetService(
                Services.V6.CustomerUserAccessService);

            // Creates the modified user access.
            CustomerUserAccess userAccess = new CustomerUserAccess()
            {
                ResourceName = ResourceNames.CustomerUserAccess(customerId, userId),
                AccessRole   = accessRole
            };

            // Creates the operation.
            CustomerUserAccessOperation operation = new CustomerUserAccessOperation()
            {
                Update     = userAccess,
                UpdateMask = FieldMasks.AllSetFieldsOf(userAccess)
            };

            // Updates the user access.
            MutateCustomerUserAccessResponse response =
                userAccessService.MutateCustomerUserAccess(
                    customerId.ToString(), operation);

            // Displays the result.
            Console.WriteLine($"Successfully modified customer user access with " +
                              $"resource name '{response.Result.ResourceName}'.");
        }
コード例 #2
0
 /// <summary>Snippet for MutateCustomerUserAccess</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateCustomerUserAccess()
 {
     // Create client
     CustomerUserAccessServiceClient customerUserAccessServiceClient = CustomerUserAccessServiceClient.Create();
     // Initialize request argument(s)
     string customerId = "";
     CustomerUserAccessOperation operation = new CustomerUserAccessOperation();
     // Make the request
     MutateCustomerUserAccessResponse response = customerUserAccessServiceClient.MutateCustomerUserAccess(customerId, operation);
 }
 /// <summary>Snippet for MutateCustomerUserAccess</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void MutateCustomerUserAccessRequestObject()
 {
     // Create client
     CustomerUserAccessServiceClient customerUserAccessServiceClient = CustomerUserAccessServiceClient.Create();
     // Initialize request argument(s)
     MutateCustomerUserAccessRequest request = new MutateCustomerUserAccessRequest
     {
         CustomerId = "",
         Operation  = new CustomerUserAccessOperation(),
     };
     // Make the request
     MutateCustomerUserAccessResponse response = customerUserAccessServiceClient.MutateCustomerUserAccess(request);
 }