View a markdown version of this page

Etiquetado de dominios (AWS SDKs) - OpenSearch Servicio Amazon

Las traducciones son generadas a través de traducción automática. En caso de conflicto entre la traducción y la version original de inglés, prevalecerá la version en inglés.

Etiquetado de dominios (AWS SDKs)

Las AWS SDKs (excepto Android e iOS SDKs) admiten todas las acciones definidas en la referencia de la API de Amazon OpenSearch Service, incluidas las AddTags RemoveTags operacionesListTags, y. Para obtener más información sobre la instalación y el uso de AWS SDKs, consulte los kits de desarrollo de AWS software.

Python

En este ejemplo, se usa el cliente Python de OpenSearchServicebajo nivel del AWS SDK para Python (Boto) para agregar una etiqueta a un dominio, enumerar la etiqueta adjunta al dominio y eliminar una etiqueta del dominio. Debe proporcionar valores para DOMAIN_ARN, TAG_KEY y TAG_VALUE.

import boto3 from botocore.config import Config # import configuration DOMAIN_ARN = '' # ARN for the domain. i.e "arn:aws:es:us-east-1:123456789012:domain/my-domain TAG_KEY = '' # The name of the tag key. i.e 'Smileyface' TAG_VALUE = '' # The value assigned to the tag. i.e 'Practicetag' # defines the configurations parameters such as region my_config = Config(region_name='us-east-1') client = boto3.client('opensearch', config=my_config) # defines the client variable def addTags(): """Adds tags to the domain""" response = client.add_tags(ARN=DOMAIN_ARN, TagList=[{'Key': TAG_KEY, 'Value': TAG_VALUE}]) print(response) def listTags(): """List tags that have been added to the domain""" response = client.list_tags(ARN=DOMAIN_ARN) print(response) def removeTags(): """Remove tags that have been added to the domain""" response = client.remove_tags(ARN=DOMAIN_ARN, TagKeys=[TAG_KEY]) print('Tag removed') return response