기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
AWSSDK 또는 CLI와 ListThings 함께 사용
다음 코드 예시는 ListThings의 사용 방법을 보여 줍니다.
- .NET
-
- SDK for .NET(v4)
-
참고
GitHub에 더 많은 내용이 있습니다. AWS코드 예 리포지토리
에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요. /// <summary> /// Lists IoT Things with pagination support. /// </summary> /// <returns>List of Things, or empty list if listing failed.</returns> public async Task<List<ThingAttribute>> ListThingsAsync() { try { // Use pages of 10. var request = new ListThingsRequest() { MaxResults = 10 }; var response = await _amazonIoT.ListThingsAsync(request); // Since there is not a built-in paginator, use the NextMarker to paginate. bool hasMoreResults = true; var things = new List<ThingAttribute>(); while (hasMoreResults) { things.AddRange(response.Things); // If NextMarker is not null, there are more results. Get the next page of results. if (!String.IsNullOrEmpty(response.NextMarker)) { request.Marker = response.NextMarker; response = await _amazonIoT.ListThingsAsync(request); } else hasMoreResults = false; } _logger.LogInformation($"Retrieved {things.Count} Things"); return things; } catch (Amazon.IoT.Model.ThrottlingException ex) { _logger.LogWarning($"Request throttled, please try again later: {ex.Message}"); return new List<ThingAttribute>(); } catch (Exception ex) { _logger.LogError($"Couldn't list Things. Here's why: {ex.Message}"); return new List<ThingAttribute>(); } }-
API 세부 정보는 API 참조의 ListThingsAWS SDK for .NET를 참조하세요.
-
- CLI
-
- AWS CLI
-
예시 1: 레지스트리의 모든 사물 나열
다음
list-things예시에서는 AWS계정의 AWSIoT 레지스트리에 정의된 사물(디바이스)을 나열합니다.aws iot list-things출력:
{ "things": [ { "thingName": "ThirdBulb", "thingTypeName": "LightBulb", "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/ThirdBulb", "attributes": { "model": "123", "wattage": "75" }, "version": 2 }, { "thingName": "MyOtherLightBulb", "thingTypeName": "LightBulb", "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyOtherLightBulb", "attributes": { "model": "123", "wattage": "75" }, "version": 3 }, { "thingName": "MyLightBulb", "thingTypeName": "LightBulb", "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyLightBulb", "attributes": { "model": "123", "wattage": "75" }, "version": 1 }, { "thingName": "SampleIoTThing", "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/SampleIoTThing", "attributes": {}, "version": 1 } ] }예시 2: 특정 속성을 가진 정의된 사물 나열
다음
list-things예시에서는 이름이wattage인 속성을 가진 사물의 목록을 표시합니다.aws iot list-things \ --attribute-namewattage출력:
{ "things": [ { "thingName": "MyLightBulb", "thingTypeName": "LightBulb", "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyLightBulb", "attributes": { "model": "123", "wattage": "75" }, "version": 1 }, { "thingName": "MyOtherLightBulb", "thingTypeName": "LightBulb", "thingArn": "arn:aws:iot:us-west-2:123456789012:thing/MyOtherLightBulb", "attributes": { "model": "123", "wattage": "75" }, "version": 3 } ] }자세한 내용은 AWS IoT 개발자 안내서의 레지스트리를 사용하여 사물을 관리하는 방법을 참조하세요.
-
API 세부 정보는 AWS CLI 명령 참조의 ListThings
를 참조하세요.
-
- Rust
-
- SDK for Rust
-
참고
GitHub에 더 많은 내용이 있습니다. AWS코드 예 리포지토리
에서 전체 예를 찾고 설정 및 실행하는 방법을 배워보세요. async fn show_things(client: &Client) -> Result<(), Error> { let resp = client.list_things().send().await?; println!("Things:"); for thing in resp.things.unwrap() { println!( " Name: {}", thing.thing_name.as_deref().unwrap_or_default() ); println!( " Type: {}", thing.thing_type_name.as_deref().unwrap_or_default() ); println!( " ARN: {}", thing.thing_arn.as_deref().unwrap_or_default() ); println!(); } println!(); Ok(()) }-
API 세부 정보는 AWS SDK for Rust API 참조의 ListThings
을 참조하세요.
-
AWSSDK 개발자 안내서 및 코드 예제의 전체 목록은 섹션을 참조하세요AWSSDKAWS IoT에서 사용. 이 주제에는 시작하기에 대한 정보와 이전 SDK 버전에 대한 세부 정보도 포함되어 있습니다.
ListCertificates
SearchIndex