Method: managedZones.patch

Applies a partial update to an existing ManagedZone.

HTTP request

PATCH https://dns.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
project

string

Identifies the project addressed by this request.

managedZone

string

Identifies the managed zone addressed by this request. Can be the managed zone name or ID.

Query parameters

Parameters
clientOperationId

string

For mutating operation requests only. An optional identifier specified by the client. Must be unique for operation resources in the Operations collection.

Request body

The request body contains an instance of ManagedZone.

Response body

If successful, the response body contains an instance of Operation.

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/ndev.clouddns.readwrite

For more information, see the Authentication Overview.

Examples

Uses the .NET client library.

// BEFORE RUNNING:
// ---------------
// 1. If not already done, enable the Google Cloud DNS API
//    and check the quota for your project at
//    https://console.developers.google.com/apis/api/dns
// 2. This sample uses Application Default Credentials for authentication.
//    If not already done, install the gcloud CLI from
//    https://cloud.google.com/sdk and run
//    `gcloud beta auth application-default login`.
//    For more information, see
//    https://developers.google.com/identity/protocols/application-default-credentials
// 3. Install the C# client library by adding a dependency on the relevant NuGet
//    package. Libraries published by Google are owned by google-apis-packages:
//    https://www.nuget.org/profiles/google-apis-packages

using Google.Apis.Auth.OAuth2;
using Google.Apis.Dns.v1;
using Google.Apis.Services;
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;

using Data = Google.Apis.Dns.v1.Data;

namespace DnsSample
{
   
public class DnsExample
   
{
       
public static void Main(string[] args)
       
{
           
DnsService dnsService = new DnsService(new BaseClientService.Initializer
           
{
               
HttpClientInitializer = GetCredential(),
               
ApplicationName = "Google-DnsSample/0.1",
           
});

           
// Identifies the project addressed by this request.
           
string project = "my-project";  // TODO: Update placeholder value.

           
// Identifies the managed zone addressed by this request. Can be the managed zone name or id.
           
string managedZone = "my-managed-zone";  // TODO: Update placeholder value.

           
// TODO: Assign values to desired properties of `requestBody`. Only assigned
           
// properties will be changed:
           
Data.ManagedZone requestBody = new Data.ManagedZone();

           
ManagedZonesResource.PatchRequest request = dnsService.ManagedZones.Patch(requestBody, project, managedZone);

           
// To execute asynchronously in an async method, replace `request.Execute()` as shown:
           
Data.Operation response = request.Execute();
           
// Data.Operation response = await request.ExecuteAsync();

           
// TODO: Change code below to process the `response` object:
           
Console.WriteLine(JsonConvert.SerializeObject(response));
       
}

       
public static GoogleCredential GetCredential()
       
{
           
GoogleCredential credential = Task.Run(() => GoogleCredential.GetApplicationDefaultAsync()).Result;
           
if (credential.IsCreateScopedRequired)
           
{
                credential
= credential.CreateScoped("https://www.googleapis.com/auth/cloud-platform");
           
}
           
return credential;
       
}
   
}
}

Uses the Java client library.

/*
 * BEFORE RUNNING:
 * ---------------
 * 1. If not already done, enable the Google Cloud DNS API
 *    and check the quota for your project at
 *    https://console.developers.google.com/apis/api/dns
 * 2. This sample uses Application Default Credentials for authentication.
 *    If not already done, install the gcloud CLI from
 *    https://cloud.google.com/sdk and run
 *    `gcloud beta auth application-default login`.
 *    For more information, see
 *    https://developers.google.com/identity/protocols/application-default-credentials
 * 3. Install the Java client library on Maven or Gradle. Check installation
 *    instructions at https://github.com/google/google-api-java-client.
 *    On other build systems, you can add the jar files to your project from
 *    https://developers.google.com/resources/api-libraries/download/dns/v1/java
 */

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.dns.Dns;
import com.google.api.services.dns.model.ManagedZone;
import com.google.api.services.dns.model.Operation;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Arrays;

public class DnsExample {
 
public static void main(String args[]) throws IOException, GeneralSecurityException {
   
// Identifies the project addressed by this request.
   
String project = "my-project"; // TODO: Update placeholder value.

   
// Identifies the managed zone addressed by this request. Can be the managed zone name or id.
   
String managedZone = "my-managed-zone"; // TODO: Update placeholder value.

   
// TODO: Assign values to desired fields of `requestBody`. Only assigned
   
// fields will be changed:
   
ManagedZone requestBody = new ManagedZone();

   
Dns dnsService = createDnsService();
   
Dns.ManagedZones.Patch request =
        dnsService
.managedZones().patch(project, managedZone, requestBody);

   
Operation response = request.execute();

   
// TODO: Change code below to process the `response` object:
   
System.out.println(response);
 
}

 
public static Dns createDnsService() throws IOException, GeneralSecurityException {
   
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
   
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();

   
GoogleCredential credential = GoogleCredential.getApplicationDefault();
   
if (credential.createScopedRequired()) {
      credential
=
          credential
.createScoped(Arrays.asList("https://www.googleapis.com/auth/cloud-platform"));
   
}

   
return new Dns.Builder(httpTransport, jsonFactory, credential)
       
.setApplicationName("Google-DnsSample/0.1")
       
.build();
 
}
}

Uses the Node.js client library.

// BEFORE RUNNING:
// ---------------
// 1. If not already done, enable the Google Cloud DNS API
//    and check the quota for your project at
//    https://console.developers.google.com/apis/api/dns
// 2. This sample uses Application Default Credentials for authentication.
//    If not already done, install the gcloud CLI from
//    https://cloud.google.com/sdk and run
//    `gcloud beta auth application-default login`.
//    For more information, see
//    https://developers.google.com/identity/protocols/application-default-credentials
// 3. Install the Node.js client library by running
//    `npm install googleapis --save`

const {google} = require('googleapis');
const dns = google.dns('v1');

async
function main () {
 
const authClient = await authorize();
 
const request = {
   
// Identifies the project addressed by this request.
    project
: 'my-project',  // TODO: Update placeholder value.

   
// Identifies the managed zone addressed by this request. Can be the managed zone name or id.
    managedZone
: 'my-managed-zone',  // TODO: Update placeholder value.

    resource
: {
     
// TODO: Add desired properties to the request body. Only these properties
     
// will be changed.
   
},

    auth
: authClient,
 
};

 
try {
   
const response = (await dns.managedZones.patch(request)).data;
   
// TODO: Change code below to process the `response` object:
    console
.log(JSON.stringify(response, null, 2));
 
} catch (err) {
    console
.error(err);
 
}
}
main
();

async
function authorize() {
 
const auth = new google.auth.GoogleAuth({
    scopes
: ['https://www.googleapis.com/auth/cloud-platform']
 
});
 
return await auth.getClient();
}

Uses the Python client library.

"""
BEFORE RUNNING:
---------------
1. If not already done, enable the Google Cloud DNS API
   and check the quota for your project at
   https://console.developers.google.com/apis/api/dns
2. This sample uses Application Default Credentials for authentication.
   If not already done, install the gcloud CLI from
   https://cloud.google.com/sdk and run
   `gcloud beta auth application-default login`.
   For more information, see
   https://developers.google.com/identity/protocols/application-default-credentials
3. Install the Python client library for Google APIs by running
   `pip install --upgrade google-api-python-client`
"""

from pprint import pprint

from googleapiclient import discovery
from oauth2client.client import GoogleCredentials

credentials
= GoogleCredentials.get_application_default()

service
= discovery.build('dns', 'v1', credentials=credentials)

# Identifies the project addressed by this request.
project
= 'my-project'  # TODO: Update placeholder value.

# Identifies the managed zone addressed by this request. Can be the managed zone name or id.
managed_zone
= 'my-managed-zone'  # TODO: Update placeholder value.

managed_zone_body
= {
   
# TODO: Add desired entries to the request body. Only assigned entries
   
# will be changed.
}

request
= service.managedZones().patch(project=project, managedZone=managed_zone, body=managed_zone_body)
response
= request.execute()

# TODO: Change code below to process the `response` dict:
pprint
(response)