public class QueryResult extends Object
It is the result of any query for the provisioning service. This class will parse the result and
return it in a best format possible. For the known formats in QueryResultType, you can
just cast the items. In case of unknown type, the items will contain a list of Strings
and you shall parse it by your own.
The provisioning service query result is composed by 2 system properties and a body. This class exposes
it with 3 getters, getType(), getContinuationToken(), and getItems().
The system properties are:
QueryResultType for the possible types and classes
to cast.
And the body is a JSON list of the specific type. For instance, if the system property type is IndividualEnrollment, the body will look like:
[
{
"registrationId":"validRegistrationId-1",
"deviceId":"ContosoDevice-1",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
},
{
"registrationId":"validRegistrationId-2",
"deviceId":"ContosoDevice-2",
"attestation":{
"type":"tpm",
"tpm":{
"endorsementKey":"validEndorsementKey"
}
},
"iotHubHostName":"ContosoIoTHub.azure-devices.net",
"provisioningStatus":"enabled"
}
]
| Modifier | Constructor and Description |
|---|---|
protected |
QueryResult()
Empty constructor
|
|
QueryResult(String type,
String body,
String continuationToken)
CONSTRUCTOR
|
| Modifier and Type | Method and Description |
|---|---|
String |
getContinuationToken()
Getter for the continuationToken.
|
Object[] |
getItems()
Getter for the items.
|
QueryResultType |
getType()
Getter for the type.
|
String |
toString()
Creates a pretty print JSON with the content of this class and subclasses.
|
public QueryResult(String type, String body, String continuationToken)
This constructor creates an instance of the QueryResult.
type - the String with type of the content in the body. It cannot be nullbody - the String with the body in a JSON list format. It cannot be null, or empty, if the type is different than `unknown`.continuationToken - the String with the continuation token. It can be null.IllegalArgumentException - If one of the provided parameters is invalid.protected QueryResult()
Used only by the tools that will deserialize this class.
public QueryResultType getType()
QueryResultType with the type of the items Objects.public String getContinuationToken()
String with the unique token that identify the next page of this query.public Object[] getItems()
Object[] with the results of the query. You can cast it using the type.QueryResultTypepublic String toString()
The result of this function is not a valid JSON for the provisioning service, it is just to provide a way to print its content.
Copyright © 2021. All rights reserved.