- HTTP request
- Path parameters
- Query parameters
- Request body
- Response body
- Authorization scopes
- Examples
- Try it!
Enumerates ResourceRecordSets that you have created but not yet deleted.
HTTP request
GET https://dns.googleapis.com/dns/v1/projects/{project}/managedZones/{managedZone}/rrsets
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
project |
Identifies the project addressed by this request. |
managed |
Identifies the managed zone addressed by this request. Can be the managed zone name or ID. |
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. |
name |
Restricts the list to return only records with this fully qualified domain name. |
type |
Restricts the list to return only records of this type. If present, the "name" parameter must also be present. |
Request body
The request body must be empty.
Response body
If successful, the response body contains data with the following structure:
JSON representation |
---|
{
"rrsets": [
{
object ( |
Fields | |
---|---|
rrsets[] |
The resource record set 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 .NET client library. Uses the Go client library. Uses the Java client library. Uses the Node.js client library. Uses the PHP client library. Uses the Google API Client Library for Python. Uses the Ruby 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 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.
ResourceRecordSetsResource.ListRequest request = dnsService.ResourceRecordSets.List(project, managedZone);
Data.ResourceRecordSetsListResponse response;
do
{
// To execute asynchronously in an async method, replace `request.Execute()` as shown:
response = request.Execute();
// response = await request.ExecuteAsync();
if (response.Rrsets == null)
{
continue;
}
foreach (Data.ResourceRecordSet resourceRecordSet in response.Rrsets)
{
// TODO: Change code below to process each `resourceRecordSet` resource:
Console.WriteLine(JsonConvert.SerializeObject(resourceRecordSet));
}
request.PageToken = response.NextPageToken;
} while (response.NextPageToken != null);
}
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;
}
}
}package main
// 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 and update the Go dependencies by running `go get -u` in the
// project directory.
import (
"fmt"
"log"
"golang.org/x/net/context"
"golang.org/x/oauth2/google"
"google.golang.org/api/dns/v1"
)
func main() {
ctx := context.Background()
c, err := google.DefaultClient(ctx, dns.CloudPlatformScope)
if err != nil {
log.Fatal(err)
}
dnsService, err := dns.New(c)
if err != nil {
log.Fatal(err)
}
// 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.
req := dnsService.ResourceRecordSets.List(project, managedZone)
if err := req.Pages(ctx, func(page *dns.ResourceRecordSetsListResponse) error {
for _, resourceRecordSet := range page.Rrsets {
// TODO: Change code below to process each `resourceRecordSet` resource:
fmt.Printf("%#v\n", resourceRecordSet)
}
return nil
}); err != nil {
log.Fatal(err)
}
}/*
* 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.ResourceRecordSet;
import com.google.api.services.dns.model.ResourceRecordSetsListResponse;
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.
Dns dnsService = createDnsService();
Dns.ResourceRecordSets.List request =
dnsService.resourceRecordSets().list(project, managedZone);
ResourceRecordSetsListResponse response;
do {
response = request.execute();
if (response.getRrsets() == null) {
continue;
}
for (ResourceRecordSet resourceRecordSet : response.getRrsets()) {
// TODO: Change code below to process each `resourceRecordSet` resource:
System.out.println(resourceRecordSet);
}
request.setPageToken(response.getNextPageToken());
} while (response.getNextPageToken() != null);
}
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();
}
}// 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.
auth: authClient,
};
let response;
do {
if (response && response.nextPageToken) {
request.pageToken = response.nextPageToken;
}
response = (await dns.resourceRecordSets.list(request)).data;
const rrsetsPage = response.rrsets;
if (rrsetsPage) {
for (let i = 0; i < rrsetsPage.length; i++) {
// TODO: Change code below to process each resource in `rrsetsPage`:
console.log(JSON.stringify(rrsetsPage[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();
}<?php
/*
* 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 PHP client library with Composer. Check installation
* instructions at https://github.com/google/google-api-php-client.
*/
// Autoload Composer.
require_once __DIR__ . '/vendor/autoload.php';
$client = new Google_Client();
$client->setApplicationName('Google-DnsSample/0.1');
$client->useApplicationDefaultCredentials();
$client->addScope('https://www.googleapis.com/auth/cloud-platform');
$service = new Google_Service_Dns($client);
// 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.
$optParams = [];
do {
$response = $service->resourceRecordSets->listResourceRecordSets($project, $managedZone, $optParams);
foreach ($response['rrsets'] as $resourceRecordSet) {
// TODO: Change code below to process each `resourceRecordSet` resource:
echo '<pre>', var_export($resourceRecordSet, true), '</pre>', "\n";
}
$optParams['pageToken'] = $response->getNextPageToken();
} while ($optParams['pageToken']);
?>"""
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`
"""
import pprint
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
service = discovery.build('dns', 'v1', credentials=credentials)
# Project ID for this request.
project = 'my-project' # TODO(developer): Update placeholder value.
# The name of the zone for this request.
managed_zone = 'my-managed-zone' # TODO(developer): Update placeholder value.
request = service.resourceRecordSets().list(project=project,
managedZone=managed_zone)
while request is not None:
response = request.execute()
for resource_record_set in response['rrsets']:
# "TODO(developer): Change to do something with each
# DNS record set in `resource_record_set`"
pprint.pprint(resource_record_set)
request = service.resourceRecordSets().list_next(previous_request=request,
previous_response=response)# 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 Ruby client library and Application Default Credentials
# library by running `gem install google-api-client` and
# `gem install googleauth`
require 'googleauth'
require 'google/apis/dns_v1'
service = Google::Apis::DnsV1::DnsService.new
service.authorization = \
Google::Auth.get_application_default(['https://www.googleapis.com/auth/cloud-platform'])
# 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.
rrsets = service.fetch_all(items: :rrsets) do |token|
service.list_resource_record_sets(project, managed_zone, page_token: token)
end
rrsets.each do |resource_record_set|
# TODO: Change code below to process each `resource_record_set` resource:
puts resource_record_set.to_json
end