Documentation
AdGuard.ApiClient.Api.DNSServersApi
All URIs are relative to https://api.adguard-dns.io
| Method | HTTP request | Description |
|---|---|---|
| CreateDNSServer | POST /oapi/v1/dns_servers | Creates a new DNS server |
| ListDNSServers | GET /oapi/v1/dns_servers | Lists DNS servers that belong to the user. |
CreateDNSServer
DNSServer CreateDNSServer (DNSServerCreate dNSServerCreate)
Creates a new DNS server
Creates a new DNS server. You can attach custom settings, otherwise DNS server will be created with default settings.
Example
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using AdGuard.ApiClient.Api;
using AdGuard.ApiClient.Client;
using AdGuard.ApiClient.Model;
namespace Example
{
public class CreateDNSServerExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.adguard-dns.io";
// Configure API key authorization: ApiKey
config.AddApiKey("Authorization", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("Authorization", "Bearer");
// Configure Bearer token for authorization: AuthToken
config.AccessToken = "YOUR_BEARER_TOKEN";
// create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
HttpClient httpClient = new HttpClient();
HttpClientHandler httpClientHandler = new HttpClientHandler();
var apiInstance = new DNSServersApi(httpClient, config, httpClientHandler);
var dNSServerCreate = new DNSServerCreate(); // DNSServerCreate |
try
{
// Creates a new DNS server
DNSServer result = apiInstance.CreateDNSServer(dNSServerCreate);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DNSServersApi.CreateDNSServer: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
Using the CreateDNSServerWithHttpInfo variant
This returns an ApiResponse object which contains the response data, status code and headers.
try
{
// Creates a new DNS server
ApiResponse<DNSServer> response = apiInstance.CreateDNSServerWithHttpInfo(dNSServerCreate);
Debug.Write("Status Code: " + response.StatusCode);
Debug.Write("Response Headers: " + response.Headers);
Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DNSServersApi.CreateDNSServerWithHttpInfo: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| dNSServerCreate | DNSServerCreate |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: /, application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | DNS server created | - |
| 400 | Validation failed | - |
| 429 | DNS servers count reached the limit | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListDNSServers
List<DNSServer> ListDNSServers ()
Lists DNS servers that belong to the user.
Lists DNS servers that belong to the user. By default there is at least one default server.
Example
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using AdGuard.ApiClient.Api;
using AdGuard.ApiClient.Client;
using AdGuard.ApiClient.Model;
namespace Example
{
public class ListDNSServersExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api.adguard-dns.io";
// Configure API key authorization: ApiKey
config.AddApiKey("Authorization", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// config.AddApiKeyPrefix("Authorization", "Bearer");
// Configure Bearer token for authorization: AuthToken
config.AccessToken = "YOUR_BEARER_TOKEN";
// create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
HttpClient httpClient = new HttpClient();
HttpClientHandler httpClientHandler = new HttpClientHandler();
var apiInstance = new DNSServersApi(httpClient, config, httpClientHandler);
try
{
// Lists DNS servers that belong to the user.
List<DNSServer> result = apiInstance.ListDNSServers();
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DNSServersApi.ListDNSServers: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
Using the ListDNSServersWithHttpInfo variant
This returns an ApiResponse object which contains the response data, status code and headers.
try
{
// Lists DNS servers that belong to the user.
ApiResponse<List<DNSServer>> response = apiInstance.ListDNSServersWithHttpInfo();
Debug.Write("Status Code: " + response.StatusCode);
Debug.Write("Response Headers: " + response.Headers);
Debug.Write("Response Body: " + response.Data);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DNSServersApi.ListDNSServersWithHttpInfo: " + e.Message);
Debug.Print("Status Code: " + e.ErrorCode);
Debug.Print(e.StackTrace);
}
Parameters
This endpoint does not need any parameter.
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: /
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | List of DNS servers | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]