View a markdown version of this page

Marquage de domaines ()AWS SDKs - Amazon OpenSearch Service

Les traductions sont fournies par des outils de traduction automatique. En cas de conflit entre le contenu d'une traduction et celui de la version originale en anglais, la version anglaise prévaudra.

Marquage de domaines ()AWS SDKs

AWS SDKs (sauf Android et iOS SDKs) prennent en charge toutes les actions définies dans le Amazon OpenSearch Service API Reference, y compris les RemoveTags opérations AddTagsListTags, et. Pour plus d'informations sur l'installation et l'utilisation du AWS SDKs, consultez la section Kits de développement AWS logiciel.

Python

Cet exemple utilise le client Python de OpenSearchServicebas niveau du AWS SDK pour Python (Boto) pour ajouter une balise à un domaine, répertorier la balise attachée au domaine et supprimer une balise du domaine. Vous devez fournir des valeurs pour DOMAIN_ARN, TAG_KEY et 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