- Descripción general del servicio
- Pasos iniciales
-
Guía del usuario
- Habilitación de HSS
- Descripción General de Riesgos
-
Gestión de activos
- Gestión de activos
- Gestión de servidores
- Gestión de contenedores
- Gestión de huellas dactilares de activos
- Gestión de cuotas de protección
- Prevención de Riesgos
- Prevención
- Detección de intrusiones
- Operaciones de seguridad
- Informe de seguridad
- Instalación & Configuración
- Auditoría
- Gestión de permisos
-
Referencia de la API
- Antes de empezar
- Invocaciones a las API
-
Descripción de la API
-
Gestión de activos
- Recopilación de estadísticas de activos, incluidas cuentas, puertos y procesos
- Consulta de la lista de cuentas
- Consulta de estadísticas de puertos abiertos
- Consulta de la lista de procesos
- Consulta de la lista de software
- Consulta de información de elementos de inicio automático
- Consulta de la lista de servidores de una cuenta
- Consulta de la lista de puertos abiertos de un único servidor
- Consulta de la lista de servidores del software
- Consulta de la lista de servicios de elementos autoarrancados
- Obtención del historial de cambios de cuenta
- Obtención de los registros históricos de cambios de la información de software
- Obtención de registros históricos de cambios de elementos iniciados automáticamente
- Huellas digitales de activos - Proceso - Lista de servidores
- Huellas digitales de activos - Puerto - Lista de servidores
- Consulta de la lista de middleware
- Consulta de la lista de servidores de un middleware especificado
-
Prevención de ransomware
- Consulta de servidores protegidos contra el ransomware
- Consulta de la lista de políticas de protección contra Ransomware
- Modificación de políticas de protección contra ransomware
- Habilitación de la prevención de ransomware
- Deshabilitación de la prevención de ransomware
- Consulta de la política de copia de respaldo vinculada al almacén de protección HSS
- Modificación de la política de copia de respaldo vinculada al almacén
-
Gestión de línea base
- Consulta de la lista de resultados de detección de contraseña débil
- Consulta del informe de detección de política de complejidad de contraseña
- Consulta de la lista de resultados de la verificación de configuración de seguridad del servidor
- Consulta del resultado de verificación de un elemento de configuración de seguridad
- Consulta de la lista de verificación de un elemento de configuración de seguridad
- Consulta de la lista de servidores afectados por un elemento de configuración de seguridad
- Consulta del informe de un elemento de comprobación en una comprobación de configuración de seguridad
- Ignorar, dejar de ignorar, reparar o verificar los elementos de verificación de configuración fallidos
- Gestión de cuotas
- Gestión de contenedor
- Gestión de evento
- Detección de intrusiones
- Gestión de servidores
-
imagen de contenedor
- Consulta de la lista de imágenes en el repositorio de imágenes SWR
- Escaneo de imágenes en el repositorio de imágenes por lotes
- Consulta de información de vulnerabilidad de imagen
- Información de CVE correspondiente a la vulnerabilidad
- Sincronización de la lista de imágenes de SWR
- Consulta de la lista de resultados de detección de configuración de seguridad de imagen
- Consulta de la lista de elementos de verificación de un elemento de configuración de seguridad especificada de una imagen
- Consulta del informe de verificación de configuración de Mirror
- Gestión de política
-
Gestión de vulnerabilidades
- Consulta de la lista de vulnerabilidades
- Consulta de los servidores afectados por una vulnerabilidad
- Cambio del estado de una vulnerabilidad
- Consulta de información de vulnerabilidad sobre un servidor
- Creación de una tarea de escaneo de vulnerabilidades
- Consulta de una política de escaneo de vulnerabilidades
- Modificación de una política de análisis de vulnerabilidades
- Consulta de las tareas de escaneo de vulnerabilidades
- Consulta de la lista de servidores correspondientes a una tarea de escaneo de vulnerabilidades
- Consulta de estadísticas de gestión de vulnerabilidades
- Protección contra manipulaciones web
- Gestión de etiquetas
-
Gestión de activos
- Apéndices
- Historial de cambio
-
Preguntas frecuentes
-
Acerca de HSS
- ¿Qué es Host Security Service?
- ¿Qué es Container Security Service?
- ¿Qué es Web Tamper Protection?
- ¿Cuáles son las relaciones entre imágenes, contenedores y aplicaciones?
- ¿Dónde está disponible el HSS?
- ¿Cómo uso HSS?
- Is HSS in Conflict with Any Other Security Software?
- ¿Cuáles son las diferencias entre HSS, VSS y WAF?
- ¿Qué es el agente de HSS?
- ¿Puedo actualizar mi HSS a una edición superior?
-
Preguntas Frecuentes de Agentes
- ¿Está el agente en conflicto con cualquier otro software de seguridad?
- ¿Cómo instalo el agente?
- ¿Cómo desinstalo el agente?
- ¿Qué debo hacer si falló la instalación del agente?
- ¿Cómo puedo arreglar un agente anormal?
- ¿Cuál es la ruta de instalación predeterminada del agente?
- ¿Cuántos recursos de CPU y memoria están ocupados por el agente cuando realiza escaneos?
- ¿WTP y HSS usan el mismo agente?
- ¿Cómo puedo ver los servidores donde no se han instalado agentes?
- ¿Qué puedo hacer si el estado del agente sigue "No instalado" después de la instalación?
- Defensa de ataque de fuerza bruta
- Contraseñas débiles y cuentas inseguras
-
Intrusiones
- ¿Qué hago si mis servidores están sujetos a un ataque minero?
- ¿Por qué un proceso todavía está aislado después de que fue incluido en la lista blanca?
- ¿Qué hago si se detecta un proceso de minería en un servidor?
- ¿Qué debo hacer si encuentro que mis servidores atacan a otros?
- ¿Por qué no se detectan algunos ataques a servidores?
- ¿Puedo desbloquear una dirección IP bloqueada por HSS y cómo?
- ¿Por qué una dirección IP bloqueada se desbloquea automáticamente?
- Inicios de sesión anormales
- Configuración insegura
- Gestión de vulnerabilidades
-
Otros
- ¿Qué son las Regiones y las AZ?
- ¿Qué debo hacer si la respuesta del teclado es lenta o si necesito ingresar dígitos consecutivos en el sistema operativo Windows chino?
- ¿Cómo uso la herramienta de conexión a escritorio remoto de Windows para conectarme a un servidor?
- ¿Cómo puedo comprobar los archivos de registro de HSS?
- ¿Cómo puedo habilitar el registro de errores de inicio de sesión?
-
Protección contra manipulación de la web
- ¿Por qué necesito agregar un directorio protegido?
- ¿Cómo modifico un directorio protegido?
- ¿Qué debo hacer si WTP no se puede habilitar?
- ¿Cómo modifico un archivo después de que WTP esté habilitado?
- ¿Qué puedo hacer si habilité el WTP dinámico pero su estado está habilitado pero no está en efecto?
- ¿Cuáles son las diferencias entre las funciones de protección contra manipulaciones Web de HSS y WAF?
- Container Guard Service
- Protección de ransomware
-
Acerca de HSS
- Actualmente, el contenido no está disponible en el idioma seleccionado. Sugerimos consultar la versión en inglés.
- What's New
- Function Overview
- Product Bulletin
- Technology Poster
- Billing
-
Best Practices
- HSS Best Practices You May Need
-
Suggestions on How to Fix Official Disclosed Vulnerabilities Provided by HSS
- Git Credential Disclosure Vulnerability (CVE-2020-5260)
- SaltStack Remote Command Execution Vulnerabilities (CVE-2020-11651 and CVE-2020-11652)
- OpenSSL High-risk Vulnerability (CVE-2020-1967)
- Adobe Font Manager Library Remote Code Execution Vulnerability (CVE-2020-1020/CVE-2020-0938)
- Windows Kernel Elevation of Privilege Vulnerability (CVE-2020-1027)
- Windows CryptoAPI Spoofing Vulnerability (CVE-2020-0601)
- Third-Party Servers Accessing HSS Through a Direct Connect and Proxy Servers
- Connecting Third-Party Servers to HSS Through Direct Connect and VPC Endpoint
- Installing the HSS Agent Using CBH
- Using HSS to Improve Server Login Security
- Using HSS and CBR to Defend Against Ransomware
- Combining WAF and HSS to Improve Web Page Tampering Protection
- Using HSS to Scan and Fix Vulnerabilities
- Using HSS to Prevent Weak Passwords
- Using HSS to Scan for Trojans
- Using HSS to Handle Mining Attacks
- Using HSS to Monitor the Integrity of Linux Server Files
- Using the Whitelist to Reduce False Alarms
- HSS Security Best Practices
- SDK Reference
- Videos
-
More Documents
-
User Guide (Ankara Region)
- Introduction
- Enabling HSS
- Server Security Dashboard
- Asset Management
- Risk Prevention
- Prevention
- Intrusion Detection
- Security Operations
- Security Report
- Installation & Configuration
- Permissions Management
-
FAQs
-
About HSS
- What Is HSS?
- What Is Container Security Service?
- What Is Web Tamper Protection?
- What Are the Relationships Between Images, Containers, and Applications?
- How Do I Use HSS?
- Can HSS Protect Local IDC Servers?
- Is HSS in Conflict with Any Other Security Software?
- What Are the Differences Between HSS and WAF?
- What Is the HSS Agent?
-
Agent FAQs
- Is the Agent in Conflict with Any Other Security Software?
- How Do I Install the Agent?
- How Do I Uninstall the Agent?
- What Should I Do If Agent Installation Failed?
- How Do I Fix an Abnormal Agent?
- What Is the Default Agent Installation Path?
- How Many CPU and Memory Resources Are Occupied by the Agent When It Performs Scans?
- Do WTP and HSS Use the Same Agent?
- How Do I View Servers Where No Agents Have Been Installed?
-
Brute-force Attack Defense
- How Does HSS Intercept Brute Force Attacks?
- How Do I Handle a Brute-force Attack Alarm?
- How Do I Defend Against Brute-force Attacks?
- How Do I Do If the Account Cracking Prevention Function Does Not Take Effect on Some Linux Accounts?
- How Do I Unblock an IP Address?
- What Do I Do If HSS Frequently Reports Brute-force Alarms?
- What Do I Do If My Remote Server Port Is Not Updated in Brute-force Attack Records?
- Weak Passwords and Unsafe Accounts
-
Intrusions
- What Do I Do If My Servers Are Subjected to a Mining Attack?
- Why a Process Is Still Isolated After It Was Whitelisted?
- What Do I Do If a Mining Process Is Detected on a Server?
- Why Some Attacks on Servers Are Not Detected?
- Can I Unblock an IP Address Blocked by HSS, and How?
- Why a Blocked IP Address Is Automatically Unblocked?
- How Often Does HSS Detect, Isolate, and Kill Malicious Programs?
- What Do I Do If an IP Address Is Blocked by HSS?
- How Do I Defend Against Ransomware Attacks?
- Abnormal Logins
- Unsafe Settings
- Vulnerability Management
-
Web Tamper Protection
- Why Do I Need to Add a Protected Directory?
- How Do I Modify a Protected Directory?
- What Should I Do If WTP Cannot Be Enabled?
- How Do I Modify a File After WTP Is Enabled?
- What Can I Do If I Enabled Dynamic WTP But Its Status Is Enabled but not in effect?
- What Are the Differences Between the Web Tamper Protection Functions of HSS and WAF?
- Container Guard Service
- Ransomware Protection
-
Security Configurations
- How Do I Clear the SSH Login IP Address Whitelist Configured in HSS?
- What Can I Do If I Cannot Remotely Log In to a Server via SSH?
- How Do I Use 2FA?
- What Do I Do If I Cannot Enable 2FA?
- Why Can't I Receive a Verification Code After 2FA Is Enabled?
- Why Does My Login Fail After I Enable 2FA?
- How Do I Add a Mobile Phone Number or Email Address for Receiving 2FA Verification Notifications?
- If I Choose to Use Verification Code for 2FA, How Do I Get the Code?
- How Do I Disable the SELinux Firewall?
- Quotas
-
Others
- How Do I Use the Windows Remote Desktop Connection Tool to Connect to a Server?
- How Do I Check HSS Log Files?
- How Do I Enable Logging for Login Failures?
- How Do I Clear an Alarm on Critical File Changes?
- Is HSS Available as Offline Software?
- How Do I Enable HSS Self-Protection?
- What Do I Do If HSS Self-Protection Cannot Be Disabled?
-
About HSS
- Change History
-
User Guide (ME-Abu Dhabi Region)
- Introduction
- Enabling HSS
- Server Security Dashboard
- Asset Management
- Risk Prevention
-
Prevention
- Application Protection
- WTP
- Ransomware Prevention
- File Integrity Monitoring
-
Container Firewalls
- Container Firewall Overview
- Creating a Policy (for a Cluster Using the Container Tunnel Network Model)
- Creating a Policy (for a Cluster Using the VPC Network Model)
- Managing Policies (for a Cluster Using the Container Tunnel Network Model)
- Managing Policies (for a Cluster Using the VPC Network Model)
- Intrusion Detection
- Security Operations
- Security Report
- Installation & Configuration
- Audit
- Permissions Management
- Manually Upgrading HSS
-
FAQs
- About HSS
-
Agent FAQs
- Is the Agent in Conflict with Any Other Security Software?
- How Do I Uninstall the Agent?
- What Should I Do If Agent Installation Failed?
- How Do I Fix an Abnormal Agent?
- What Is the Default Agent Installation Path?
- How Many CPU and Memory Resources Are Occupied by the Agent When It Performs Scans?
- Do WTP and HSS Use the Same Agent?
- How Do I View Servers Where No Agents Have Been Installed?
- What Can I Do If the Agent Status Is Still "Not installed" After Installation?
- What Do I Do If the HSS Upgrade Fails?
-
Brute-force Attack Defense
- How Does HSS Intercept Brute Force Attacks?
- How Do I Handle a Brute-force Attack Alarm?
- How Do I Defend Against Brute-force Attacks?
- What Do I Do If the Account Cracking Prevention Function Does Not Take Effect on Some Accounts for Linux Servers?
- How Do I Unblock an IP Address?
- What Do I Do If HSS Frequently Reports Brute-force Alarms?
- What Do I Do If My Remote Server Port Is Not Updated in Brute-force Attack Records?
- Weak Passwords and Unsafe Accounts
-
Intrusions
- What Do I Do If My Servers Are Subjected to a Mining Attack?
- Why a Process Is Still Isolated After It Was Whitelisted?
- What Do I Do If a Mining Process Is Detected on a Server?
- Why Some Attacks on Servers Are Not Detected?
- Can I Unblock an IP Address Blocked by HSS, and How?
- Why a Blocked IP Address Is Automatically Unblocked?
- How Often Does HSS Detect, Isolate, and Kill Malicious Programs?
- What Do I Do If an IP Address Is Blocked by HSS?
- How Do I Defend Against Ransomware Attacks?
- Abnormal Logins
- Unsafe Settings
- Vulnerability Management
-
Web Tamper Protection
- Why Do I Need to Add a Protected Directory?
- How Do I Modify a Protected Directory?
- What Should I Do If WTP Cannot Be Enabled?
- How Do I Modify a File After WTP Is Enabled?
- What Can I Do If I Enabled Dynamic WTP But Its Status Is Enabled but not in effect?
- What Are the Differences Between the Web Tamper Protection Functions of HSS and WAF?
- Container Guard Service
-
Security Configurations
- What Can I Do If I Cannot Remotely Log In to a Server via SSH?
- How Do I Use 2FA?
- Why Can't I Receive a Verification Code After 2FA Is Enabled?
- Why Does My Login Fail After I Enable 2FA?
- How Do I Add a Mobile Phone Number or Email Address for Receiving 2FA Verification Notifications?
- How Do I Disable the SELinux Firewall?
- Others
- Change History
-
User Guide (Paris)
- Introduction
- Enabling HSS
- Server Security Dashboard
-
Asset Management
- Asset Management
- Server Fingerprints
- Container Fingerprints
- Server Management
- Container Management
- Risk Prevention
-
Prevention
- WTP
- Ransomware Prevention
- File Integrity Monitoring
-
Container Firewalls
- Container Firewall Overview
- Creating a Policy (for a Cluster Using the Container Tunnel Network Model)
- Creating a Policy (for a Cluster Using the VPC Network Model)
- Managing Policies (for a Cluster Using the Container Tunnel Network Model)
- Managing Policies (for a Cluster Using the VPC Network Model)
- Intrusion Detection
- Security Operations
- Security Report
- Installation & Configuration
- Audit
- Permissions Management
- Manually Upgrading HSS
-
FAQs
- About HSS
-
Agent FAQs
- Is the Agent in Conflict with Any Other Security Software?
- How Do I Uninstall the Agent?
- What Should I Do If Agent Installation Failed?
- How Do I Fix an Abnormal Agent?
- What Is the Default Agent Installation Path?
- How Many CPU and Memory Resources Are Occupied by the Agent When It Performs Scans?
- Do WTP and HSS Use the Same Agent?
- How Do I View Servers Where No Agents Have Been Installed?
- What Can I Do If the Agent Status Is Still "Not installed" After Installation?
- What Addresses Do ECSs Access After the Agent Is Installed?
-
Brute-force Attack Defense
- How Does HSS Intercept Brute Force Attacks?
- How Do I Handle a Brute-force Attack Alarm?
- How Do I Defend Against Brute-force Attacks?
- What Do I Do If the Account Cracking Prevention Function Does Not Take Effect on Some Accounts for Linux Servers?
- How Do I Unblock an IP Address?
- What Do I Do If HSS Frequently Reports Brute-force Alarms?
- What Do I Do If My Remote Server Port Is Not Updated in Brute-force Attack Records?
- Weak Passwords and Unsafe Accounts
-
Intrusions
- What Do I Do If My Servers Are Subjected to a Mining Attack?
- Why a Process Is Still Isolated After It Was Whitelisted?
- What Do I Do If a Mining Process Is Detected on a Server?
- Why Some Attacks on Servers Are Not Detected?
- Can I Unblock an IP Address Blocked by HSS, and How?
- Why a Blocked IP Address Is Automatically Unblocked?
- How Often Does HSS Detect, Isolate, and Kill Malicious Programs?
- What Do I Do If an IP Address Is Blocked by HSS?
- How Do I Defend Against Ransomware Attacks?
- Abnormal Logins
- Unsafe Settings
-
Vulnerability Management
- How Do I Fix Vulnerabilities?
- What Do I Do If an Alarm Still Exists After I Fixed a Vulnerability?
- Why a Server Displayed in Vulnerability Information Does Not Exist?
- Do I Need to Restart a Server After Fixing its Vulnerabilities?
- Can I Check the Vulnerability and Baseline Fix History on HSS?
- What Do I Do If Vulnerability Fix Failed?
- Why Can't I Select a Server During Manual Vulnerability Scanning or Batch Vulnerability Fixing?
-
Web Tamper Protection
- Why Do I Need to Add a Protected Directory?
- How Do I Modify a Protected Directory?
- What Should I Do If WTP Cannot Be Enabled?
- How Do I Modify a File After WTP Is Enabled?
- What Can I Do If I Enabled Dynamic WTP But Its Status Is Enabled but not in effect?
- What Are the Differences Between the Web Tamper Protection Functions of HSS and WAF?
- Container Guard Service
-
Security Configurations
- How Do I Clear the SSH Login IP Address Whitelist Configured in HSS?
- What Can I Do If I Cannot Remotely Log In to a Server via SSH?
- How Do I Use 2FA?
- What Do I Do If I Cannot Enable 2FA?
- Why Can't I Receive a Verification Code After 2FA Is Enabled?
- Why Does My Login Fail After I Enable 2FA?
- How Do I Add a Mobile Phone Number or Email Address for Receiving 2FA Verification Notifications?
- If I Choose to Use Verification Code for 2FA, How Do I Get the Code?
- How Do I Modify Alarm Notification Recipients?
- Why No Topics Are Available for Me to Choose When I Configure Alarm Notifications?
- Can I Disable HSS Alarm Notifications?
- How Do I Modify Alarm Notification Items?
- How Do I Disable the SELinux Firewall?
-
Others
- How Do I Use the Windows Remote Desktop Connection Tool to Connect to a Server?
- How Do I Check HSS Log Files?
- How Do I Enable Logging for Login Failures?
- How Do I Clear an Alarm on Critical File Changes?
- Is HSS Available as Offline Software?
- Why Is a Deleted ECS Still Displayed in the HSS Server List?
- Change History
-
User Guide (Ankara Region)
Copiado.
Creación de etiquetas por lotes
Función
Esta API se utiliza para crear etiquetas por lotes.
Método de invocación
Para obtener más información, consulte Invocación a las API.
URI
POST /v5/{project_id}/{resource_type}/{resource_id}/tags/create
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
project_id |
Sí |
String |
ID de proyecto Mínimo: 1 Máximo: 256 |
resource_type |
Yes |
String |
Tipo de recurso definido por TMS. Cuando HSS invoca a la API, el tipo de recurso es HSS. Mínimo: 1 Máximo: 64 |
resource_id |
Sí |
String |
ID de recurso definido por TMS. Cuando el HSS invoca a la API, el ID del recurso es el ID de la cuota. Mínimo: 0 Máximo: 128 |
Parámetros de solicitud
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
X-Auth-Token |
Sí |
String |
Token de usuario. Se puede obtener invocando a la API de IAM utilizada para obtener un token de usuario. El valor de X-Subject-Token en el encabezado de respuesta es un token. Mínimo: 32 Máximo: 512 |
Content-Type |
No |
String |
Valor predeterminado: application/json; charset=utf-8 Mínimo: 0 Máximo: 128 |
Parámetro |
Obligatorio |
Tipo |
Descripción |
---|---|---|---|
tags |
Sí |
Array of ResourceTagInfo objects |
Lista de etiquetas Longitud de matriz: 0 - 1024 |
Parámetros de respuesta
Ninguna
Solicitudes de ejemplo
Crear una clave de etiqueta TESTKEY20220831190155 (el valor de la etiqueta es 2) y una prueba de clave de etiqueta (el valor de la etiqueta es hss).
POST https://{endpoint}/v5/05e1e8b7ba8010dd2f80c01070a8d4cd/hss/fbaa9aca-2b5f-11ee-8c64-fa163e139e02/tags/create
{
"tags" : [ {
"key" : "TESTKEY20220831190155",
"value" : "2"
}, {
"key" : "test",
"value" : "hss"
} ]
}
Ejemplo de respuestas
Ninguna
Código de ejemplo del SDK
El código de ejemplo del SDK es el siguiente.
Java
Crear una clave de etiqueta TESTKEY20220831190155 (el valor de la etiqueta es 2) y una prueba de clave de etiqueta (el valor de la etiqueta es hss).
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.hss.v5.region.HssRegion;
import com.huaweicloud.sdk.hss.v5.*;
import com.huaweicloud.sdk.hss.v5.model.*;
import java.util.List;
import java.util.ArrayList;
public class BatchCreateTagsSolution {
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);
HssClient client = HssClient.newBuilder()
.withCredential(auth)
.withRegion(HssRegion.valueOf("<YOUR REGION>"))
.build();
BatchCreateTagsRequest request = new BatchCreateTagsRequest();
BatchCreateTagsRequestInfo body = new BatchCreateTagsRequestInfo();
List<ResourceTagInfo> listbodyTags = new ArrayList<>();
listbodyTags.add(
new ResourceTagInfo()
.withKey("TESTKEY20220831190155")
.withValue("2")
);
listbodyTags.add(
new ResourceTagInfo()
.withKey("test")
.withValue("hss")
);
body.withTags(listbodyTags);
request.withBody(body);
try {
BatchCreateTagsResponse response = client.batchCreateTags(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
Crear una clave de etiqueta TESTKEY20220831190155 (el valor de la etiqueta es 2) y una prueba de clave de etiqueta (el valor de la etiqueta es hss).
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 |
# coding: utf-8
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkhss.v5.region.hss_region import HssRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkhss.v5 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")
credentials = BasicCredentials(ak, sk) \
client = HssClient.new_builder() \
.with_credentials(credentials) \
.with_region(HssRegion.value_of("<YOUR REGION>")) \
.build()
try:
request = BatchCreateTagsRequest()
listTagsbody = [
ResourceTagInfo(
key="TESTKEY20220831190155",
value="2"
),
ResourceTagInfo(
key="test",
value="hss"
)
]
request.body = BatchCreateTagsRequestInfo(
tags=listTagsbody
)
response = client.batch_create_tags(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
Crear una clave de etiqueta TESTKEY20220831190155 (el valor de la etiqueta es 2) y una prueba de clave de etiqueta (el valor de la etiqueta es hss).
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 |
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
hss "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/model"
region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/hss/v5/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 := hss.NewHssClient(
hss.HssClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
WithCredential(auth).
Build())
request := &model.BatchCreateTagsRequest{}
var listTagsbody = []model.ResourceTagInfo{
{
Key: "TESTKEY20220831190155",
Value: "2",
},
{
Key: "test",
Value: "hss",
},
}
request.Body = &model.BatchCreateTagsRequestInfo{
Tags: listTagsbody,
}
response, err := client.BatchCreateTags(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, consulte la pestaña Código de ejemplo en API Explorer. El código de ejemplo del SDK se puede generar automáticamente.
Códigos de estado
Código de estado |
Descripción |
---|---|
200 |
Con éxito |
400 |
Parámetro no válido. |
401 |
Error de autenticación. |
403 |
Permiso insuficiente. |
404 |
Recursos no encontrados. |
500 |
Error del sistema. |
Códigos de error
Consulte Códigos de error.