mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 08:16:39 +00:00
[management] Add custom dns zones (#4849)
This commit is contained in:
@@ -25,6 +25,8 @@ tags:
|
||||
description: Interact with and view information about routes.
|
||||
- name: DNS
|
||||
description: Interact with and view information about DNS configuration.
|
||||
- name: DNS Zones
|
||||
description: Interact with and view information about custom DNS zones.
|
||||
- name: Events
|
||||
description: View information about the account and network events.
|
||||
- name: Accounts
|
||||
@@ -1779,6 +1781,100 @@ components:
|
||||
example: ch8i4ug6lnn4g9hqv7m0
|
||||
required:
|
||||
- disabled_management_groups
|
||||
ZoneRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
description: Zone name identifier
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
example: Office Zone
|
||||
domain:
|
||||
description: Zone domain (FQDN)
|
||||
type: string
|
||||
example: example.com
|
||||
enabled:
|
||||
description: Zone status
|
||||
type: boolean
|
||||
default: true
|
||||
enable_search_domain:
|
||||
description: Enable this zone as a search domain
|
||||
type: boolean
|
||||
example: false
|
||||
distribution_groups:
|
||||
description: Group IDs that defines groups of peers that will resolve this zone
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
example: ch8i4ug6lnn4g9hqv7m0
|
||||
required:
|
||||
- name
|
||||
- domain
|
||||
- enable_search_domain
|
||||
- distribution_groups
|
||||
Zone:
|
||||
allOf:
|
||||
- type: object
|
||||
properties:
|
||||
id:
|
||||
description: Zone ID
|
||||
type: string
|
||||
example: ch8i4ug6lnn4g9hqv7m0
|
||||
records:
|
||||
description: DNS records associated with this zone
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/DNSRecord'
|
||||
required:
|
||||
- id
|
||||
- enabled
|
||||
- records
|
||||
- $ref: '#/components/schemas/ZoneRequest'
|
||||
DNSRecordType:
|
||||
type: string
|
||||
description: DNS record type
|
||||
enum:
|
||||
- A
|
||||
- AAAA
|
||||
- CNAME
|
||||
example: A
|
||||
DNSRecordRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
description: FQDN for the DNS record. Must be a subdomain within or match the zone's domain.
|
||||
type: string
|
||||
example: www.example.com
|
||||
type:
|
||||
$ref: '#/components/schemas/DNSRecordType'
|
||||
content:
|
||||
description: DNS record content (IP address for A/AAAA, domain for CNAME)
|
||||
type: string
|
||||
maxLength: 255
|
||||
minLength: 1
|
||||
example: 192.168.1.1
|
||||
ttl:
|
||||
description: Time to live in seconds
|
||||
type: integer
|
||||
minimum: 0
|
||||
example: 300
|
||||
required:
|
||||
- name
|
||||
- type
|
||||
- content
|
||||
- ttl
|
||||
DNSRecord:
|
||||
allOf:
|
||||
- type: object
|
||||
properties:
|
||||
id:
|
||||
description: DNS record ID
|
||||
type: string
|
||||
example: ch8i4ug6lnn4g9hqv7m0
|
||||
required:
|
||||
- id
|
||||
- $ref: '#/components/schemas/DNSRecordRequest'
|
||||
Event:
|
||||
type: object
|
||||
properties:
|
||||
@@ -4733,6 +4829,347 @@ paths:
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
/api/dns/zones:
|
||||
get:
|
||||
summary: List all DNS Zones
|
||||
description: Returns a list of all custom DNS zones
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Array of DNS Zones
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Zone'
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
post:
|
||||
summary: Create a DNS Zone
|
||||
description: Creates a new custom DNS zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
requestBody:
|
||||
description: A DNS zone object
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/ZoneRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Object of the created DNS Zone
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Zone'
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
/api/dns/zones/{zoneId}:
|
||||
get:
|
||||
summary: Retrieve a DNS Zone
|
||||
description: Returns information about a specific DNS zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Object of a DNS Zone
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Zone'
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
put:
|
||||
summary: Update a DNS Zone
|
||||
description: Updates a custom DNS zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
requestBody:
|
||||
description: A DNS zone object
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/ZoneRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Object of the updated DNS Zone
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Zone'
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
delete:
|
||||
summary: Delete a DNS Zone
|
||||
description: Deletes a custom DNS zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
responses:
|
||||
'200':
|
||||
description: Zone deletion successful
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
/api/dns/zones/{zoneId}/records:
|
||||
get:
|
||||
summary: List all DNS Records
|
||||
description: Returns a list of all DNS records in a zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Array of DNS Records
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/DNSRecord'
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
post:
|
||||
summary: Create a DNS Record
|
||||
description: Creates a new DNS record in a zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
requestBody:
|
||||
description: A DNS record object
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/DNSRecordRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Object of the created DNS Record
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DNSRecord'
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
/api/dns/zones/{zoneId}/records/{recordId}:
|
||||
get:
|
||||
summary: Retrieve a DNS Record
|
||||
description: Returns information about a specific DNS record
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
- in: path
|
||||
name: recordId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a DNS record
|
||||
example: chacbco6lnnbn6cg5s92
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Object of a DNS Record
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DNSRecord'
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
put:
|
||||
summary: Update a DNS Record
|
||||
description: Updates a DNS record in a zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
- in: path
|
||||
name: recordId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a DNS record
|
||||
example: chacbco6lnnbn6cg5s92
|
||||
requestBody:
|
||||
description: A DNS record object
|
||||
content:
|
||||
'application/json':
|
||||
schema:
|
||||
$ref: '#/components/schemas/DNSRecordRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: A JSON Object of the updated DNS Record
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/DNSRecord'
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
delete:
|
||||
summary: Delete a DNS Record
|
||||
description: Deletes a DNS record from a zone
|
||||
tags: [ DNS Zones ]
|
||||
security:
|
||||
- BearerAuth: [ ]
|
||||
- TokenAuth: [ ]
|
||||
parameters:
|
||||
- in: path
|
||||
name: zoneId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a zone
|
||||
example: chacbco6lnnbn6cg5s91
|
||||
- in: path
|
||||
name: recordId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
description: The unique identifier of a DNS record
|
||||
example: chacbco6lnnbn6cg5s92
|
||||
responses:
|
||||
'200':
|
||||
description: Record deletion successful
|
||||
'400':
|
||||
"$ref": "#/components/responses/bad_request"
|
||||
'401':
|
||||
"$ref": "#/components/responses/requires_authentication"
|
||||
'403':
|
||||
"$ref": "#/components/responses/forbidden"
|
||||
'404':
|
||||
"$ref": "#/components/responses/not_found"
|
||||
'500':
|
||||
"$ref": "#/components/responses/internal_error"
|
||||
/api/events/audit:
|
||||
get:
|
||||
summary: List all Audit Events
|
||||
|
||||
@@ -12,6 +12,13 @@ const (
|
||||
TokenAuthScopes = "TokenAuth.Scopes"
|
||||
)
|
||||
|
||||
// Defines values for DNSRecordType.
|
||||
const (
|
||||
DNSRecordTypeA DNSRecordType = "A"
|
||||
DNSRecordTypeAAAA DNSRecordType = "AAAA"
|
||||
DNSRecordTypeCNAME DNSRecordType = "CNAME"
|
||||
)
|
||||
|
||||
// Defines values for EventActivityCode.
|
||||
const (
|
||||
EventActivityCodeAccountCreate EventActivityCode = "account.create"
|
||||
@@ -427,6 +434,42 @@ type CreateSetupKeyRequest struct {
|
||||
UsageLimit int `json:"usage_limit"`
|
||||
}
|
||||
|
||||
// DNSRecord defines model for DNSRecord.
|
||||
type DNSRecord struct {
|
||||
// Content DNS record content (IP address for A/AAAA, domain for CNAME)
|
||||
Content string `json:"content"`
|
||||
|
||||
// Id DNS record ID
|
||||
Id string `json:"id"`
|
||||
|
||||
// Name FQDN for the DNS record. Must be a subdomain within or match the zone's domain.
|
||||
Name string `json:"name"`
|
||||
|
||||
// Ttl Time to live in seconds
|
||||
Ttl int `json:"ttl"`
|
||||
|
||||
// Type DNS record type
|
||||
Type DNSRecordType `json:"type"`
|
||||
}
|
||||
|
||||
// DNSRecordRequest defines model for DNSRecordRequest.
|
||||
type DNSRecordRequest struct {
|
||||
// Content DNS record content (IP address for A/AAAA, domain for CNAME)
|
||||
Content string `json:"content"`
|
||||
|
||||
// Name FQDN for the DNS record. Must be a subdomain within or match the zone's domain.
|
||||
Name string `json:"name"`
|
||||
|
||||
// Ttl Time to live in seconds
|
||||
Ttl int `json:"ttl"`
|
||||
|
||||
// Type DNS record type
|
||||
Type DNSRecordType `json:"type"`
|
||||
}
|
||||
|
||||
// DNSRecordType DNS record type
|
||||
type DNSRecordType string
|
||||
|
||||
// DNSSettings defines model for DNSSettings.
|
||||
type DNSSettings struct {
|
||||
// DisabledManagementGroups Groups whose DNS management is disabled
|
||||
@@ -1999,6 +2042,48 @@ type UserRequest struct {
|
||||
Role string `json:"role"`
|
||||
}
|
||||
|
||||
// Zone defines model for Zone.
|
||||
type Zone struct {
|
||||
// DistributionGroups Group IDs that defines groups of peers that will resolve this zone
|
||||
DistributionGroups []string `json:"distribution_groups"`
|
||||
|
||||
// Domain Zone domain (FQDN)
|
||||
Domain string `json:"domain"`
|
||||
|
||||
// EnableSearchDomain Enable this zone as a search domain
|
||||
EnableSearchDomain bool `json:"enable_search_domain"`
|
||||
|
||||
// Enabled Zone status
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// Id Zone ID
|
||||
Id string `json:"id"`
|
||||
|
||||
// Name Zone name identifier
|
||||
Name string `json:"name"`
|
||||
|
||||
// Records DNS records associated with this zone
|
||||
Records []DNSRecord `json:"records"`
|
||||
}
|
||||
|
||||
// ZoneRequest defines model for ZoneRequest.
|
||||
type ZoneRequest struct {
|
||||
// DistributionGroups Group IDs that defines groups of peers that will resolve this zone
|
||||
DistributionGroups []string `json:"distribution_groups"`
|
||||
|
||||
// Domain Zone domain (FQDN)
|
||||
Domain string `json:"domain"`
|
||||
|
||||
// EnableSearchDomain Enable this zone as a search domain
|
||||
EnableSearchDomain bool `json:"enable_search_domain"`
|
||||
|
||||
// Enabled Zone status
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
|
||||
// Name Zone name identifier
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
// GetApiEventsNetworkTrafficParams defines parameters for GetApiEventsNetworkTraffic.
|
||||
type GetApiEventsNetworkTrafficParams struct {
|
||||
// Page Page number
|
||||
@@ -2083,6 +2168,18 @@ type PutApiDnsNameserversNsgroupIdJSONRequestBody = NameserverGroupRequest
|
||||
// PutApiDnsSettingsJSONRequestBody defines body for PutApiDnsSettings for application/json ContentType.
|
||||
type PutApiDnsSettingsJSONRequestBody = DNSSettings
|
||||
|
||||
// PostApiDnsZonesJSONRequestBody defines body for PostApiDnsZones for application/json ContentType.
|
||||
type PostApiDnsZonesJSONRequestBody = ZoneRequest
|
||||
|
||||
// PutApiDnsZonesZoneIdJSONRequestBody defines body for PutApiDnsZonesZoneId for application/json ContentType.
|
||||
type PutApiDnsZonesZoneIdJSONRequestBody = ZoneRequest
|
||||
|
||||
// PostApiDnsZonesZoneIdRecordsJSONRequestBody defines body for PostApiDnsZonesZoneIdRecords for application/json ContentType.
|
||||
type PostApiDnsZonesZoneIdRecordsJSONRequestBody = DNSRecordRequest
|
||||
|
||||
// PutApiDnsZonesZoneIdRecordsRecordIdJSONRequestBody defines body for PutApiDnsZonesZoneIdRecordsRecordId for application/json ContentType.
|
||||
type PutApiDnsZonesZoneIdRecordsRecordIdJSONRequestBody = DNSRecordRequest
|
||||
|
||||
// PostApiGroupsJSONRequestBody defines body for PostApiGroups for application/json ContentType.
|
||||
type PostApiGroupsJSONRequestBody = GroupRequest
|
||||
|
||||
|
||||
Reference in New Issue
Block a user