Method: policies.create

Creates a new Policy.

HTTP request

POST https://dns.googleapis.com/dns/v1/projects/{project}/policies

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
project

string

Identifies the project addressed by this request.

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 Policy.

Response body

If successful, the response body contains a newly created instance of Policy.

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

Node.js

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.

    resource
: {
     
// TODO: Add desired properties to the request body.
   
},

    auth
: authClient,
 
};

 
try {
   
const response = (await dns.policies.create(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();
}