- HTTP request
- Path parameters
- Query parameters
- Request body
- Response body
- Authorization scopes
- Examples
- Try it!
Enumerates all Policies associated with a project.
HTTP request
GET https://dns.googleapis.com/dns/v1/projects/{project}/policies
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
project |
Identifies the project addressed by this request. |
Query parameters
Parameters | |
---|---|
max |
Optional. Maximum number of results to be returned. If unspecified, the server decides how many results to return. |
page |
Optional. A tag returned by a previous list request that was truncated. Use this parameter to continue a previous list request. |
Request body
The request body must be empty.
Response body
If successful, the response body contains data with the following structure:
JSON representation |
---|
{
"policies": [
{
object ( |
Fields | |
---|---|
policies[] |
The policy resources. |
next |
This field indicates that more results are available beyond the last page displayed. To fetch the results, make another list request and use this value as your page token. This lets you retrieve the complete contents of a very large collection one page at a time. However, if the contents of the collection change between the first and last paginated list request, the set of all elements returned are an inconsistent view of the collection. You can't retrieve a consistent snapshot of a collection larger than the maximum page size. |
kind |
Type of resource. |
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/cloud-platform.read-only
https://www.googleapis.com/auth/ndev.clouddns.readonly
https://www.googleapis.com/auth/ndev.clouddns.readwrite
For more information, see the Authentication Overview.
Uses the Node.js client library.Examples
// 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.
auth: authClient,
};
let response;
do {
if (response && response.nextPageToken) {
request.pageToken = response.nextPageToken;
}
response = (await dns.policies.list(request)).data;
const policiesPage = response.policies;
if (policiesPage) {
for (let i = 0; i < policiesPage.length; i++) {
// TODO: Change code below to process each resource in `policiesPage`:
console.log(JSON.stringify(policiesPage[i], null, 2));
}
}
} while (response.nextPageToken);
}
main();
async function authorize() {
const auth = new google.auth.GoogleAuth({
scopes: ['https://www.googleapis.com/auth/cloud-platform']
});
return await auth.getClient();
}