Aumento das especificações da instância
Função
Essa API é usada para modificar as especificações da instância. Atualmente, essa API só pode ser usada para aumentar as especificações de instâncias de pagamento por uso.
Método de chamada
Para obter detalhes, consulte Chamada de APIs.
URI
POST /v2/{engine}/{project_id}/instances/{instance_id}/extend
Parâmetro |
Obrigatório |
Tipo |
Descrição |
---|---|---|---|
engine |
Sim |
String |
Mecanismo de mensagens. Padrão: kafka |
project_id |
Sim |
String |
ID do projeto. Para obter detalhes sobre como obtê-lo, consulte Obtenção de um ID de projeto. |
instance_id |
Sim |
String |
ID da instância. |
Parâmetros de solicitação
Parâmetro |
Obrigatório |
Tipo |
Descrição |
---|---|---|---|
oper_type |
Sim |
String |
Tipo de mudança. Intervalo de valores:
|
new_storage_space |
Não |
Integer |
Novo espaço de armazenamento. Este parâmetro é válido e obrigatório quando oper_type é definido como storage ou horizontal. Espaço de armazenamento da instância = Número de corretores x Espaço de armazenamento de cada corretor. Se oper_type estiver definido como storage, o número de corretores permanece inalterado e o espaço de armazenamento de cada corretor deve ser expandido em pelo menos 100 GB.
|
new_broker_num |
Não |
Integer |
Este parâmetro é válido somente quando oper_type é definido como horizontal. Intervalo de valores: um máximo de 30 corretores são suportados. |
new_product_id |
Não |
String |
Novo ID de produto para aumento de escala. Este parâmetro é válido e obrigatório quando oper_type é definido como vertical. Obtenha o ID do produto a partir da Consulta à lista de especificações do produto. |
publicip_id |
Não |
String |
ID do EIP vinculado à instância. Use vírgulas (,) para separar vários IDs de EIP. Este parâmetro é obrigatório quando oper_type é definido como horizontal. |
tenant_ips |
Não |
Array of strings |
Endereços IP privados IPv4 especificados. O número de endereços IP especificados deve ser menor ou igual ao número de novos corretores. Se o número de endereços IP especificados for menor que o número de corretores, os corretores não especificados receberão endereços IP privados aleatoriamente atribuídos. |
second_tenant_subnet_id |
Não |
String |
ID da sub-rede em espera usada pelos novos corretores na expansão da instância. Esse valor é transferido quando uma sub-rede em espera é usada na expansão da instância. Entre em contato com o atendimento ao cliente para usar o valor. |
Parâmetros de resposta
Código de status: 200
Parâmetro |
Tipo |
Descrição |
---|---|---|
job_id |
String |
ID da tarefa de modificação da especificação. |
Exemplo de solicitações
- Expansão do espaço de armazenamento (pagamento por uso)
POST https://{endpoint}/v2/{engine}/{project_id}/instances/{instance_id}/extend { "oper_type" : "storage", "new_storage_space" : 600 }
- Adição de corretores (pagamento por uso)
POST https://{endpoint}/v2/{engine}/{project_id}/instances/{instance_id}/extend { "oper_type" : "horizontal", "new_storage_space" : 1600, "new_broker_num" : 4, "tenant_ips" : [ "127.0.0.1", "127.0.0.2", "127.0.0.3" ] }
- Aumento do flavor do corretor (pagamento por uso)
POST https://{endpoint}/v2/{engine}/{project_id}/instances/{instance_id}/extend { "oper_type" : "vertical", "new_product_id" : "c6.4u8g.cluster" }
Exemplo de respostas
Código de status: 200
Especificações de instância aumentadas.
{ "job_id" : "93b94287-728d-4bb1-a158-cb66cb0854e7" }
Código de exemplo do SDK
O código de exemplo do SDK é o seguinte.
Java
- Expansão do espaço de armazenamento (pagamento por uso)
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
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.kafka.v2.region.KafkaRegion; import com.huaweicloud.sdk.kafka.v2.*; import com.huaweicloud.sdk.kafka.v2.model.*; public class ResizeEngineInstanceSolution { 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"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); KafkaClient client = KafkaClient.newBuilder() .withCredential(auth) .withRegion(KafkaRegion.valueOf("<YOUR REGION>")) .build(); ResizeEngineInstanceRequest request = new ResizeEngineInstanceRequest(); request.withEngine(ResizeEngineInstanceRequest.EngineEnum.fromValue("{engine}")); request.withInstanceId("{instance_id}"); ResizeEngineInstanceReq body = new ResizeEngineInstanceReq(); body.withNewStorageSpace(600); body.withOperType("storage"); request.withBody(body); try { ResizeEngineInstanceResponse response = client.resizeEngineInstance(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()); } } }
- Adição de corretores (pagamento por uso)
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
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.kafka.v2.region.KafkaRegion; import com.huaweicloud.sdk.kafka.v2.*; import com.huaweicloud.sdk.kafka.v2.model.*; import java.util.List; import java.util.ArrayList; public class ResizeEngineInstanceSolution { 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"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); KafkaClient client = KafkaClient.newBuilder() .withCredential(auth) .withRegion(KafkaRegion.valueOf("<YOUR REGION>")) .build(); ResizeEngineInstanceRequest request = new ResizeEngineInstanceRequest(); request.withEngine(ResizeEngineInstanceRequest.EngineEnum.fromValue("{engine}")); request.withInstanceId("{instance_id}"); ResizeEngineInstanceReq body = new ResizeEngineInstanceReq(); List<String> listbodyTenantIps = new ArrayList<>(); listbodyTenantIps.add("127.0.0.1"); listbodyTenantIps.add("127.0.0.2"); listbodyTenantIps.add("127.0.0.3"); body.withTenantIps(listbodyTenantIps); body.withNewBrokerNum(4); body.withNewStorageSpace(1600); body.withOperType("horizontal"); request.withBody(body); try { ResizeEngineInstanceResponse response = client.resizeEngineInstance(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()); } } }
- Aumento do flavor do corretor (pagamento por uso)
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
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.kafka.v2.region.KafkaRegion; import com.huaweicloud.sdk.kafka.v2.*; import com.huaweicloud.sdk.kafka.v2.model.*; public class ResizeEngineInstanceSolution { 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"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); KafkaClient client = KafkaClient.newBuilder() .withCredential(auth) .withRegion(KafkaRegion.valueOf("<YOUR REGION>")) .build(); ResizeEngineInstanceRequest request = new ResizeEngineInstanceRequest(); request.withEngine(ResizeEngineInstanceRequest.EngineEnum.fromValue("{engine}")); request.withInstanceId("{instance_id}"); ResizeEngineInstanceReq body = new ResizeEngineInstanceReq(); body.withNewProductId("c6.4u8g.cluster"); body.withOperType("vertical"); request.withBody(body); try { ResizeEngineInstanceResponse response = client.resizeEngineInstance(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
- Expansão do espaço de armazenamento (pagamento por uso)
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
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkkafka.v2.region.kafka_region import KafkaRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkkafka.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 = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) \ client = KafkaClient.new_builder() \ .with_credentials(credentials) \ .with_region(KafkaRegion.value_of("<YOUR REGION>")) \ .build() try: request = ResizeEngineInstanceRequest() request.engine = "{engine}" request.instance_id = "{instance_id}" request.body = ResizeEngineInstanceReq( new_storage_space=600, oper_type="storage" ) response = client.resize_engine_instance(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
- Adição de corretores (pagamento por uso)
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
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkkafka.v2.region.kafka_region import KafkaRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkkafka.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 = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) \ client = KafkaClient.new_builder() \ .with_credentials(credentials) \ .with_region(KafkaRegion.value_of("<YOUR REGION>")) \ .build() try: request = ResizeEngineInstanceRequest() request.engine = "{engine}" request.instance_id = "{instance_id}" listTenantIpsbody = [ "127.0.0.1", "127.0.0.2", "127.0.0.3" ] request.body = ResizeEngineInstanceReq( tenant_ips=listTenantIpsbody, new_broker_num=4, new_storage_space=1600, oper_type="horizontal" ) response = client.resize_engine_instance(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg)
- Aumento do flavor do corretor (pagamento por uso)
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
# coding: utf-8 from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkkafka.v2.region.kafka_region import KafkaRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkkafka.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 = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) \ client = KafkaClient.new_builder() \ .with_credentials(credentials) \ .with_region(KafkaRegion.value_of("<YOUR REGION>")) \ .build() try: request = ResizeEngineInstanceRequest() request.engine = "{engine}" request.instance_id = "{instance_id}" request.body = ResizeEngineInstanceReq( new_product_id="c6.4u8g.cluster", oper_type="vertical" ) response = client.resize_engine_instance(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
- Expansão do espaço de armazenamento (pagamento por uso)
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" kafka "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/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") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := kafka.NewKafkaClient( kafka.KafkaClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ResizeEngineInstanceRequest{} request.Engine = model.GetResizeEngineInstanceRequestEngineEnum().ENGINE request.InstanceId = "{instance_id}" newStorageSpaceResizeEngineInstanceReq:= int32(600) request.Body = &model.ResizeEngineInstanceReq{ NewStorageSpace: &newStorageSpaceResizeEngineInstanceReq, OperType: "storage", } response, err := client.ResizeEngineInstance(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
- Adição de corretores (pagamento por uso)
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" kafka "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/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") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := kafka.NewKafkaClient( kafka.KafkaClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ResizeEngineInstanceRequest{} request.Engine = model.GetResizeEngineInstanceRequestEngineEnum().ENGINE request.InstanceId = "{instance_id}" var listTenantIpsbody = []string{ "127.0.0.1", "127.0.0.2", "127.0.0.3", } newBrokerNumResizeEngineInstanceReq:= int32(4) newStorageSpaceResizeEngineInstanceReq:= int32(1600) request.Body = &model.ResizeEngineInstanceReq{ TenantIps: &listTenantIpsbody, NewBrokerNum: &newBrokerNumResizeEngineInstanceReq, NewStorageSpace: &newStorageSpaceResizeEngineInstanceReq, OperType: "horizontal", } response, err := client.ResizeEngineInstance(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
- Aumento do flavor do corretor (pagamento por uso)
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
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" kafka "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/kafka/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") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := kafka.NewKafkaClient( kafka.KafkaClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ResizeEngineInstanceRequest{} request.Engine = model.GetResizeEngineInstanceRequestEngineEnum().ENGINE request.InstanceId = "{instance_id}" newProductIdResizeEngineInstanceReq:= "c6.4u8g.cluster" request.Body = &model.ResizeEngineInstanceReq{ NewProductId: &newProductIdResizeEngineInstanceReq, OperType: "vertical", } response, err := client.ResizeEngineInstance(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } }
Mais
Para obter o código de exemplo do SDK de mais linguagens de programação, consulte a guia Código de exemplo no API Explorer. O código de exemplo do SDK pode ser gerado automaticamente.
Códigos de status
Código de status |
Descrição |
---|---|
200 |
Especificações de instância aumentadas. |
Códigos de erro
Consulte Códigos de erro.