Agrega etiquetas a un bucket o modifica las etiquetas existentes.
Notas de uso
De forma predeterminada, una cuenta de Alibaba Cloud tiene los permisos necesarios para agregar etiquetas a un bucket o modificarlas. Si desea usar un usuario de RAM o Security Token Service (STS) para esta tarea, debe contar con el permiso
oss:PutBucketTags. Para obtener más información, consulte Attach a custom policy to a RAM user.Al ejecutar el comando put-bucket-tags para agregar etiquetas a un bucket, las etiquetas nuevas sobrescriben las existentes.
Puede configurar hasta 20 etiquetas por bucket. Cada etiqueta es un par clave-valor.
Sintaxis del comando
ossutil api put-bucket-tags --bucket value --tagging value [flags]
|
Parámetro |
Tipo |
Descripción |
|
--bucket |
string |
El nombre del bucket. |
|
--tagging |
string |
El contenedor donde se almacenan las etiquetas. |
El comando put-bucket-tags corresponde a la operación PutBucketTags. Para conocer más detalles sobre los parámetros de esta operación, consulte PutBucketTags.
--tagging
La opción --tagging es compatible con los formatos XML y JSON. Si el valor de la opción incluye el prefijo file://, ossutil lee la configuración desde un archivo de configuración.
-
Formato XML:
<Tagging> <TagSet> <Tag> <Key>string</Key> <Value>string</Value> </Tag> ... </TagSet> </Tagging> -
Formato JSON:
{ "TagSet": { "Tag": [ { "Key": "string", "Value": "string" }, ... ] } }
Para obtener más información sobre las opciones globales de línea de comandos compatibles, consulte Global command-line options.
Ejemplos
A continuación se muestra cómo agregar etiquetas al bucket examplebucket o modificar las que ya tiene.
-
Cree un archivo de configuración llamado tagging.xml y agregue el código siguiente:
<?xml version="1.0" encoding="UTF-8"?> <Tagging> <TagSet> <Tag> <Key>key1</Key> <Value>value1</Value> </Tag> <Tag> <Key>key2</Key> <Value>value2</Value> </Tag> </TagSet> </Tagging>
Comando de ejemplo:
ossutil api put-bucket-tags --bucket examplebucket --tagging file://tagging.xml
-
Cree un archivo de configuración llamado tagging.json y agregue el código siguiente:
{ "TagSet": { "Tag": [ { "Key": "key1", "Value": "value1" }, { "Key": "key2", "Value": "value2" } ] } }Comando de ejemplo:
ossutil api put-bucket-tags --bucket examplebucket --tagging file://tagging.json -
Configure los parámetros del comando siguiente en formato JSON:
ossutil api put-bucket-tags --bucket examplebucket --tagging "{\"TagSet\":{\"Tag\":[{\"Key\":\"key1\",\"Value\":\"value1\"},{\"Key\":\"key2\",\"Value\":\"value2\"}]}}"