

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.

# Gérer les choses avec le registre
<a name="thing-registry"></a>

Vous utilisez la AWS IoT console, AWS IoT l'API ou le AWS CLI pour interagir avec le registre. Les sections suivantes montrent comment utiliser l'interface de ligne de commande pour qu'elle fonctionne avec le registre.

**Lorsque vous nommez vos objets objets :**
+ N'utilisez pas d'informations personnellement identifiables dans le nom de votre objet. Le nom de l'objet peut apparaître dans les communications et les rapports non chiffrés. 

**Topics**
+ [Créer un objet](create-thing.md)
+ [Liste des objets](list-things.md)
+ [Décrivez des objets](search-things.md)
+ [Mettre à jour un objet](update-thing.md)
+ [Supprimer un objet](delete-thing.md)
+ [Attacher un mandataire à un objet](attach-thing-principal.md)
+ [Énumérer les éléments associés à un directeur](list-principal-things.md)
+ [Lister les principes associés à un objet](list-thing-principals.md)
+ [Lister les éléments associés à une V2 principale](list-principal-things-v2.md)
+ [Répertorier les principes associés à un objet V2](list-thing-principals-v2.md)
+ [Détacher un mandataire d'un objet](detach-thing-principal.md)

# Créer un objet
<a name="create-thing"></a>

La commande suivante montre comment utiliser la AWS IoT **CreateThing** commande de la CLI pour créer un objet. Vous ne pouvez pas changer le nom d'un objet une fois qu’il est créé. Pour modifier le nom d'un objet, créez-en un nouveau, donnez-lui le nouveau nom, puis supprimez l'ancien. 

```
$ aws iot create-thing \
    --thing-type-name "MyLightBulb" \ 
    --attribute-payload "{\"attributes\": {\"wattage\":\"75\", \"model\":\"123\"}}"
```

La commande **CreateThing** affiche le nom et l’Amazon Resource Name (ARN) de votre nouvel objet :

```
{
    "thingArn": "arn:aws:iot:us-east-1:123456789012:thing/MyLightBulb",
    "thingName": "MyLightBulb",
    "thingId": "12345678abcdefgh12345678ijklmnop12345678"
}
```

**Note**  
Nous vous déconseillons d'utiliser des informations personnelles identifiables dans le nom de vos objets.

Pour plus d'informations, consultez [create-thing](https://docs.aws.amazon.com//cli/latest/reference/iot/create-thing.html) dans la AWS CLI Référence des commandes.

# Liste des objets
<a name="list-things"></a>

Vous pouvez utiliser la commande **ListThings** pour répertorier tous les objets présents dans votre compte :

```
$ aws iot list-things
```

```
{
    "things": [
       {
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MyLightBulb"
        },
        {
            "attributes": {
                "numOfStates":"3"
             },
            "version": 11,
            "thingName": "MyWallSwitch"
        }
    ]
}
```

Vous pouvez utiliser **ListThings** la commande pour chercher tous les objets d’un type d’objet specifique :

```
$  aws iot list-things --thing-type-name "LightBulb"
```

```
{
    "things": [
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MyRGBLight"
        },
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MySecondLightBulb"
        }
    ]
}
```

Vous pouvez utiliser la **ListThings** commande pour rechercher tous les objets qui ont un attribut avec une valeur spécifique : Cette commande recherche jusqu'à trois attributs. 

```
$  aws iot list-things --attribute-name "wattage" --attribute-value "75"
```

```
{
    "things": [
        {
            "thingTypeName": "StopLight",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 3,
            "thingName": "MyLightBulb"
        },
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MyRGBLight"
        },
        {
            "thingTypeName": "LightBulb",
            "attributes": {
                "model": "123",
                "wattage": "75"
            },
            "version": 1,
            "thingName": "MySecondLightBulb"
        }
    ]
}
```

Pour plus d'informations, veuillez consulter [list-objects](https://docs.aws.amazon.com//cli/latest/reference/iot/list-things.html) dans la AWS CLI Référence des commandes .

# Décrivez des objets
<a name="search-things"></a>

Pour afficher des informations sur un objet, vous pouvez utiliser la commande **DescribeThing** :

```
$ aws iot describe-thing --thing-name "MyLightBulb"
{
    "version": 3,
    "thingName": "MyLightBulb",
    "thingArn": "arn:aws:iot:us-east-1:123456789012:thing/MyLightBulb",
    "thingId": "12345678abcdefgh12345678ijklmnop12345678",
    "defaultClientId": "MyLightBulb",
    "thingTypeName": "StopLight",
    "attributes": {
        "model": "123",
        "wattage": "75"
    }
}
```

Vous pouvez également accéder à cette API dans le moteur de règles à l'aide de la fonction `get_registry_data()` en ligne. Vous pouvez utiliser cette fonction pour accéder et utiliser de manière dynamique les informations du registre des objets (y compris les attributs, les types d'objets et les appartenances à des groupes) en appelant `DescribeThing` et `ListThingGroupsForThing` APIs directement dans le cadre des AWS IoT règles, ce qui permet le traitement et le routage des messages en temps réel en fonction des données du registre de votre appareil. Pour de plus amples informations, veuillez consulter [https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data).

Pour plus d'informations, consultez [describe-thing dans le manuel](https://docs.aws.amazon.com//cli/latest/reference/iot/describe-thing.html) de référence des AWS CLI commandes.

# Mettre à jour un objet
<a name="update-thing"></a>

Vous pouvez utiliser la commande **UpdateThing** pour mettre à jour un objet : Cette commande met à jour uniquement les attributs de l'objet. Vous ne pouvez pas changer le nom d'un objet. Pour modifier le nom d'un objet, créez-en un nouveau, donnez-lui le nouveau nom, puis supprimez l'ancien.

```
$ aws iot update-thing --thing-name "MyLightBulb" --attribute-payload "{\"attributes\": {\"wattage\":\"150\", \"model\":\"456\"}}"
```

La commande **UpdateThing** ne génère pas de sortie. Vous pouvez voir le résultat à l'aide de la commande **DescribeThing** :

```
$ aws iot describe-thing --thing-name "MyLightBulb"
{
    "attributes": {
        "model": "456",
        "wattage": "150"
    },
    "version": 2,
    "thingName": "MyLightBulb"
}
```

Pour plus d'informations, consultez [update-thing](https://docs.aws.amazon.com//cli/latest/reference/iot/update-thing.html) dans la AWS CLI Référence de commande.

# Supprimer un objet
<a name="delete-thing"></a>

Vous pouvez utiliser la commande **DeleteThing** pour supprimer un objet :

```
$ aws iot delete-thing --thing-name "MyThing"
```

Cette commande renvoie un message de succès de l'opération sans erreur si la suppression a été réussie ou que vous spécifiez un objet qui n'existe pas.

Pour plus d'informations, veuillez consulter [delete-thing](https://docs.aws.amazon.com//cli/latest/reference/iot/delete-thing.html) dans la AWS CLI Référence des commandes.

# Attacher un mandataire à un objet
<a name="attach-thing-principal"></a>

Un appareil physique peut utiliser un principal pour communiquer avec AWS IoT. Le principal peut être un certificat X.509 ou un identifiant Amazon Cognito. Vous pouvez associer un certificat ou un identifiant Amazon Cognito à l'élément du registre qui représente votre appareil en exécutant la [attach-thing-principal](https://docs.aws.amazon.com//cli/latest/reference/iot/attach-thing-principal.html)commande.

Pour associer un certificat ou un identifiant Amazon Cognito à votre objet, utilisez la [attach-thing-principal](https://docs.aws.amazon.com//cli/latest/reference/iot/attach-thing-principal.html)commande suivante :

```
$ aws iot attach-thing-principal \
    --thing-name "MyLightBulb1" \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/a0c01f5835079de0a7514643d68ef8414ab739a1e94ee4162977b02b12842847"
```

Pour joindre un certificat à votre objet avec un type de pièce jointe (pièce jointe exclusive ou pièce jointe non exclusive), utilisez la [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/attach-thing-principal.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/attach-thing-principal.html)commande et spécifiez un type dans le `--thing-principal-type` champ. Une pièce jointe exclusive signifie que votre objet IoT est le seul élément attaché au certificat, et que ce certificat ne peut être associé à aucun autre élément. Une pièce jointe non exclusive signifie que votre objet IoT est associé au certificat et que ce certificat peut être associé à d'autres éléments. Pour de plus amples informations, veuillez consulter [Associer un AWS IoT objet à une connexion client MQTT](exclusive-thing.md).

**Note**  
Pour [Associer un AWS IoT objet à une connexion client MQTT](exclusive-thing.md) cette fonctionnalité, vous ne pouvez utiliser le certificat X.509 qu'en tant que principal.

```
$ aws iot attach-thing-principal \
    --thing-name "MyLightBulb2" \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/a0c01f5835079de0a7514643d68ef8414ab739a1e94ee4162977b02b12842847" \
    --thing-principal-type "EXCLUSIVE_THING"
```

Si la pièce jointe est réussie, la **AttachThingPrincipal** commande ne produit aucune sortie. Pour décrire la pièce jointe, utilisez la commande list-thing-principals-v 2 CLI.

Pour plus d'informations, consultez la *référence [AttachThingPrincipal](https://docs.aws.amazon.com//iot/latest/apireference/API_AttachThingPrincipal.html)de AWS IoT Core l'API*.

# Énumérer les éléments associés à un directeur
<a name="list-principal-things"></a>

Pour répertorier les éléments associés au principal spécifié, exécutez la [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-things.htmls](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-things.htmls)commande. Notez que cette commande ne répertorie pas le type de pièce jointe entre l'objet et le certificat. Pour répertorier le type de pièce jointe, utilisez la [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html)commande. Pour de plus amples informations, veuillez consulter [Lister les éléments associés à une V2 principale](list-principal-things-v2.md).

```
$ aws iot list-principal-things \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
```

Le résultat peut ressembler à ce qui suit.

```
{
    "things": [
        "MyLightBulb1",
        "MyLightBulb2"
    ]
}
```

Pour plus d'informations, consultez la *référence [ListPrincipalThings](https://docs.aws.amazon.com//iot/latest/apireference/API_ListPrincipalThings.html)de AWS IoT Core l'API*.

# Lister les principes associés à un objet
<a name="list-thing-principals"></a>

Pour répertorier les principes associés à l'objet spécifié, exécutez la [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principals.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principals.html)commande. Notez que cette commande ne répertorie pas le type de pièce jointe entre l'objet et le certificat. Pour répertorier le type de pièce jointe, utilisez la [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html)commande. Pour de plus amples informations, veuillez consulter [Répertorier les principes associés à un objet V2](list-thing-principals-v2.md).

```
$ aws iot list-thing-principals \
    --thing-name "MyLightBulb1"
```

Le résultat peut ressembler à ce qui suit.

```
{
    "principals": [
         "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8",
         "arn:aws:iot:us-east-1:123456789012:cert/1a234b39b4b68278f2e9d84bf97eac2cbf4a1c28b23ea29a44559b9bcf8d395b"
    ]
}
```

Pour plus d'informations, consultez la *référence [ListThingPrincipals](https://docs.aws.amazon.com//iot/latest/apireference/API_ListThingPrincipals.html)de AWS IoT Core l'API*.

# Lister les éléments associés à une V2 principale
<a name="list-principal-things-v2"></a>

Pour répertorier les éléments associés au certificat spécifié, ainsi que le type de pièce jointe, exécutez la [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-principal-thingsv2.html)commande. Le type de pièce jointe fait référence à la manière dont le certificat est attaché à l'objet.

```
$ aws iot list-principal-things-v2 \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
```

Le résultat peut ressembler à ce qui suit.

```
{
    "PrincipalThingObjects": [
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "thing": "arn:aws:iot:us-east-1:123456789012:thing/thing_1"
        }, 
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "thing": "arn:aws:iot:us-east-1:123456789012:thing/thing_2"
        }

    ]
}
```

Pour plus d'informations, reportez-vous à la section [ListPrincipalThingsV2](https://docs.aws.amazon.com//iot/latest/apireference/API_ListPrincipalThingsV2.html) du Guide de *référence des AWS IoT Core API*.

# Répertorier les principes associés à un objet V2
<a name="list-thing-principals-v2"></a>

Pour répertorier les certificats associés à l'objet spécifié, ainsi que le type de pièce jointe, exécutez la [https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/iot/list-thing-principalsv2.html)commande. Le type de pièce jointe fait référence à la manière dont le certificat est attaché à l'objet.

```
$ aws iot list-thing-principals-v2 \
    --thing-name "thing_1"
```

Le résultat peut ressembler à ce qui suit.

```
{
    "ThingPrincipalObjects": [
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "principal": "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
        },
        {
            "thingPrincipalType": "NON_EXCLUSIVE_THING",
            "principal": "arn:aws:iot:us-east-1:123456789012:cert/1a234b39b4b68278f2e9d84bf97eac2cbf4a1c28b23ea29a44559b9bcf8d395b"
        }
    ]
}
```

Pour plus d'informations, reportez-vous à la section [ListThingsPrincipalV2](https://docs.aws.amazon.com//iot/latest/apireference/API_ListThingPrincipalsV2.html) du Guide de *référence des AWS IoT Core API*.

# Détacher un mandataire d'un objet
<a name="detach-thing-principal"></a>

Vous pouvez utiliser la commande `DetachThingPrincipal` pour détacher un certificat d'un objet :

```
$ aws iot detach-thing-principal \
    --thing-name "MyLightBulb" \
    --principal "arn:aws:iot:us-east-1:123456789012:cert/2e1eb273792174ec2b9bf4e9b37e6c6c692345499506002a35159767055278e8"
```

La **DetachThingPrincipal** commande ne génère pas de sortie.

Pour plus d'informations, consultez la *référence [detach-thing-principal](https://docs.aws.amazon.com//iot/latest/apireference/API_DetachThingPrincipal.html)de AWS IoT Core l'API*.