Estos contenidos se han traducido de forma automática para su comodidad, pero Huawei Cloud no garantiza la exactitud de estos. Para consultar los contenidos originales, acceda a la versión en inglés.
Cómputo
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Redes
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Gestión y gobernanza
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
Cloud Operations Center
Resource Governance Center
Migración
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Análisis
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
IoT
IoT Device Access
Otros
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Seguridad y cumplimiento
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Blockchain
Blockchain Service
Servicios multimedia
Media Processing Center
Video On Demand
Live
SparkRTC
Almacenamiento
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Contenedores
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Bases de datos
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Aplicaciones empresariales
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Data Lake Factory
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Distribución de contenido y cómputo de borde
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Soluciones
SAP Cloud
High Performance Computing
Servicios para desarrolladores
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
Cloud Application Engine
aPaaS MacroVerse
KooPhone
KooDrive

Creación de una zona privada

Actualización más reciente 2024-09-14 GMT+08:00

Función

Esta API se utiliza para crear una zona privada.

Método de invocación

Para obtener más información, consulte Invocación a las API.

URI

POST /v2/zones

Parámetros de solicitud

Tabla 1 Parámetros de encabezado de solicitud

Parámetro

Obligatorio

Tipo

Descripción

X-Auth-Token

String

Token de usuario. Se puede obtener mediante invocación a una API de IAM. El valor de X-Subject-Token en el encabezado de respuesta es el token de usuario.

Tabla 2 Parámetros de cuerpo de solicitud

Parámetro

Obligatorio

Tipo

Descripción

name

String

Zona a crear

description

No

String

Descripción de la zona

zone_type

String

Tipo de zona. El valor es private.

email

No

String

Dirección de correo electrónico del administrador de la zona

ttl

No

Integer

Duración del almacenamiento en caché del conjunto de registros SOA (en segundos)

router

Router object

VPC a disociar

proxy_pattern

No

String

Modo de proxy de resolución recursiva para nombres de subdominios de zonas privadas.

Opciones de valor:

  • AUTHORITY: No se realiza la resolución recursiva para esta zona.

  • RECURSIVE: Habilitar el proxy de resolución recursiva.

tags

No

Array of tag objects

Etiqueta del recurso

enterprise_project_id

No

String

ID del proyecto de empresa asociado a la zona. El valor contiene un máximo de 36 caracteres. El valor predeterminado es 0.

Tabla 3 Router

Parámetro

Obligatorio

Tipo

Descripción

router_id

String

ID de la VPC asociada a la zona

router_region

No

String

Región de la VPC

status

No

String

Estado del recurso

Tabla 4 tag

Parámetro

Obligatorio

Tipo

Descripción

key

String

Clave de etiqueta. Una clave puede contener hasta 36 caracteres Unicode. No se puede dejar en blanco. Un valor de etiqueta no puede contener caracteres especiales (=*<>,|/) ni empezar o terminar con espacios.

value

No

String

Valor de etiqueta. Un valor de etiqueta contiene un máximo de 43 caracteres de Unicode y se puede dejar en blanco. Un valor de etiqueta no puede contener caracteres especiales (=*<>,|/) ni empezar o terminar con espacios.

Parámetros de respuesta

Código de estado: 202

Tabla 5 Parámetros de cuerpo de respuesta

Parámetro

Tipo

Descripción

id

String

ID de zona, que es un UUID utilizado para identificar la zona

name

String

Nombre de la zona

description

String

Descripción de la zona

email

String

Dirección de correo electrónico del administrador de la zona

zone_type

String

Tipo de zona. El valor es private.

ttl

Integer

Valor de TTL del registro de SOA establecido en la zona

serial

Integer

Número de secuencia utilizado para identificar cambios en el archivo de zona en el conjunto de registros de SOA de la zona. El número de secuencia se utiliza para la sincronización entre los nodos maestro y esclavo. Este parámetro está reservado.

status

String

Estado del recurso

record_num

Integer

Número de conjuntos de registros en la zona

proxy_pattern

String

Modo de proxy de resolución recursiva para nombres de subdominios de zonas privadas.

Opciones de valor:

  • AUTHORITY: No se realiza la resolución recursiva para esta zona.

  • RECURSIVE: Habilitar el proxy de resolución recursiva.

pool_id

String

ID de grupo de la zona, que es asignado por el sistema

project_id

String

ID del proyecto de la zona

created_at

String

Hora en la que se creó la zona. El formato de hora UTC es AAAA-MM-DDTHH:MM:SSZ.

updated_at

String

Hora en la que se actualizó la zona. El formato de hora UTC es AAAA-MM-DDTHH:MM:SSZ.

links

pageLink object

Enlace del recurso actual u otros recursos relacionados. Cuando una respuesta se divide en páginas, se proporciona un siguiente enlace para recuperar todos los resultados.

masters

Array of strings

Servidores de DNS maestros, de los cuales los servidores esclavos obtienen información de DNS

router

RouterWithStatus object

Lista de VPC asociada a la zona

Tabla 7 RouterWithStatus

Parámetro

Tipo

Descripción

status

String

Estado del recurso

router_id

String

ID de la VPC asociada a la zona

router_region

String

Región de la VPC

Código de estado: 400

Tabla 8 Parámetros de cuerpo de respuesta

Parámetro

Tipo

Descripción

code

String

Código de error

Mínimo: 8

Máximo: 36

message

String

Descripción

Mínimo: 2

Máximo: 512

Código de estado: 404

Tabla 9 Parámetros de cuerpo de respuesta

Parámetro

Tipo

Descripción

code

String

Código de error

Mínimo: 8

Máximo: 36

message

String

Descripción

Mínimo: 2

Máximo: 512

Código de estado: 500

Tabla 10 Parámetros de cuerpo de respuesta

Parámetro

Tipo

Descripción

code

String

Código de error

Mínimo: 8

Máximo: 36

message

String

Descripción

Mínimo: 2

Máximo: 512

Ejemplo de las solicitudes

Creación de una zona privada y configuración del modo proxy de resolución recursiva en AUTHORITY para subdominios

POST https://{endpoint}/v2/zones

{
  "name" : "example.com.",
  "description" : "This is an example zone.",
  "zone_type" : "private",
  "email" : "xx@example.org",
  "router" : {
    "router_id" : "19664294-0bf6-4271-ad3a-94b8c79c6558",
    "router_region" : "xx"
  },
  "proxy_pattern" : "AUTHORITY",
  "tags" : [ {
    "key" : "key1",
    "value" : "value1"
  } ]
}

Ejemplo de las respuestas

Código de estado: 202

Respuesta a la solicitud de creación de una zona privada

{
  "id" : "ff8080825b8fc86c015b94bc6f8712c3",
  "name" : "example.com.",
  "description" : "This is an example zone.",
  "email" : "xx@example.com",
  "ttl" : 300,
  "serial" : 1,
  "masters" : [ ],
  "status" : "PENDING_CREATE",
  "links" : {
    "self" : "https://Endpoint/v2/zones/ff8080825b8fc86c015b94bc6f8712c3"
  },
  "pool_id" : "ff8080825ab738f4015ab7513298010e",
  "project_id" : "e55c6f3dc4e34c9f86353b664ae0e70c",
  "zone_type" : "private",
  "created_at" : "2017-04-22T08:17:08.997",
  "updated_at" : null,
  "record_num" : 0,
  "proxy_pattern" : "AUTHORITY",
  "router" : {
    "status" : "PENDING_CREATE",
    "router_id" : "19664294-0bf6-4271-ad3a-94b8c79c6558",
    "router_region" : "xx"
  }
}

Código de muestra del SDK

El código de ejemplo del SDK es el siguiente.

Java

Creación de una zona privada y configuración del modo proxy de resolución recursiva en AUTHORITY para subdominios

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dns.v2.region.DnsRegion;
import com.huaweicloud.sdk.dns.v2.*;
import com.huaweicloud.sdk.dns.v2.model.*;

import java.util.List;
import java.util.ArrayList;

public class CreatePrivateZoneSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");

        ICredential auth = new BasicCredentials()
                .withAk(ak)
                .withSk(sk);

        DnsClient client = DnsClient.newBuilder()
                .withCredential(auth)
                .withRegion(DnsRegion.valueOf("cn-north-4"))
                .build();
        CreatePrivateZoneRequest request = new CreatePrivateZoneRequest();
        CreatePrivateZoneReq body = new CreatePrivateZoneReq();
        List<Tag> listbodyTags = new ArrayList<>();
        listbodyTags.add(
            new Tag()
                .withKey("key1")
                .withValue("value1")
        );
        Router routerbody = new Router();
        routerbody.withRouterId("19664294-0bf6-4271-ad3a-94b8c79c6558")
            .withRouterRegion("xx");
        body.withTags(listbodyTags);
        body.withProxyPattern("AUTHORITY");
        body.withRouter(routerbody);
        body.withEmail("xx@example.org");
        body.withZoneType("private");
        body.withDescription("This is an example zone.");
        body.withName("example.com.");
        request.withBody(body);
        try {
            CreatePrivateZoneResponse response = client.createPrivateZone(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Python

Creación de una zona privada y configuración del modo proxy de resolución recursiva en AUTHORITY para subdominios

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdns.v2.region.dns_region import DnsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdns.v2 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.getenv("CLOUD_SDK_AK")
    sk = os.getenv("CLOUD_SDK_SK")

    credentials = BasicCredentials(ak, sk) \

    client = DnsClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(DnsRegion.value_of("cn-north-4")) \
        .build()

    try:
        request = CreatePrivateZoneRequest()
        listTagsbody = [
            Tag(
                key="key1",
                value="value1"
            )
        ]
        routerbody = Router(
            router_id="19664294-0bf6-4271-ad3a-94b8c79c6558",
            router_region="xx"
        )
        request.body = CreatePrivateZoneReq(
            tags=listTagsbody,
            proxy_pattern="AUTHORITY",
            router=routerbody,
            email="xx@example.org",
            zone_type="private",
            description="This is an example zone.",
            name="example.com."
        )
        response = client.create_private_zone(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Go

Creación de una zona privada y configuración del modo proxy de resolución recursiva en AUTHORITY para subdominios

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dns "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dns/v2"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dns/v2/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dns/v2/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        Build()

    client := dns.NewDnsClient(
        dns.DnsClientBuilder().
            WithRegion(region.ValueOf("cn-north-4")).
            WithCredential(auth).
            Build())

    request := &model.CreatePrivateZoneRequest{}
	valueTags:= "value1"
	var listTagsbody = []model.Tag{
        {
            Key: "key1",
            Value: &valueTags,
        },
    }
	routerRegionRouter:= "xx"
	routerbody := &model.Router{
		RouterId: "19664294-0bf6-4271-ad3a-94b8c79c6558",
		RouterRegion: &routerRegionRouter,
	}
	proxyPatternCreatePrivateZoneReq:= "AUTHORITY"
	emailCreatePrivateZoneReq:= "xx@example.org"
	descriptionCreatePrivateZoneReq:= "This is an example zone."
	request.Body = &model.CreatePrivateZoneReq{
		Tags: &listTagsbody,
		ProxyPattern: &proxyPatternCreatePrivateZoneReq,
		Router: routerbody,
		Email: &emailCreatePrivateZoneReq,
		ZoneType: "private",
		Description: &descriptionCreatePrivateZoneReq,
		Name: "example.com.",
	}
	response, err := client.CreatePrivateZone(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

Más información

Para obtener un código de ejemplo del SDK de más lenguajes de programación, consulta la pestaña Código de ejemplo en Explorador de API. El código de ejemplo del SDK se puede generar automáticamente.

Códigos de estado

Código de estado

Descripción

202

Respuesta a la solicitud de creación de una zona privada

400

Respuesta de error

404

Respuesta de error

500

Respuesta de error

Códigos de error

Consulte Códigos de error.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Comentarios

Comentarios

Comentarios

0/500

Seleccionar contenido

Enviar el contenido seleccionado con los comentarios