Weather.GetWeathersAsync Método
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Retorna uma lista paginada de dados meteorológicos.
public virtual Azure.AsyncPageable<BinaryData> GetWeathersAsync (string partyId, string boundaryId, string extensionId, string weatherDataType, string granularity, DateTimeOffset? startDateTime = default, DateTimeOffset? endDateTime = default, int? maxPageSize = default, string skipToken = default, Azure.RequestContext context = default);
abstract member GetWeathersAsync : string * string * string * string * string * Nullable<DateTimeOffset> * Nullable<DateTimeOffset> * Nullable<int> * string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
override this.GetWeathersAsync : string * string * string * string * string * Nullable<DateTimeOffset> * Nullable<DateTimeOffset> * Nullable<int> * string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
Public Overridable Function GetWeathersAsync (partyId As String, boundaryId As String, extensionId As String, weatherDataType As String, granularity As String, Optional startDateTime As Nullable(Of DateTimeOffset) = Nothing, Optional endDateTime As Nullable(Of DateTimeOffset) = Nothing, Optional maxPageSize As Nullable(Of Integer) = Nothing, Optional skipToken As String = Nothing, Optional context As RequestContext = Nothing) As AsyncPageable(Of BinaryData)
Parâmetros
- partyId
- String
ID da festa.
- boundaryId
- String
ID de limite.
- extensionId
- String
ID da extensão meteorológica.
- weatherDataType
- String
Tipo de dados meteorológicos (previsão/histórico).
- granularity
- String
Granularidade dos dados meteorológicos (diariamente/por hora).
- startDateTime
- Nullable<DateTimeOffset>
Os dados meteorológicos iniciam a data e hora UTC (inclusive), formato de exemplo: aaaa-MM-ddTHH:mm:ssZ.
- endDateTime
- Nullable<DateTimeOffset>
Data de término dos dados meteorológicos UTC date-time (inclusive), formato de exemplo: aaaa-MM-ddTHH:mm:ssZ.
Número máximo de itens necessários (inclusivo). Mínimo = 10, Máximo = 1000, Valor padrão = 50.
- skipToken
- String
Ignore o token para obter o próximo conjunto de resultados.
- context
- RequestContext
O contexto de solicitação, que pode substituir os comportamentos padrão do pipeline do cliente por chamada.
Retornos
O AsyncPageable<T> do serviço que contém uma lista de BinaryData objetos. Os detalhes do esquema do corpo de cada item na coleção estão na seção Comentários abaixo.
Exceções
partyId
, boundaryId
, extensionId
weatherDataType
ou granularity
é nulo.
O serviço retornou um código de status sem êxito.
Exemplos
Este exemplo mostra como chamar GetWeathersAsync com os parâmetros necessários e analisar o resultado.
var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetWeatherClient(<2022-11-01-preview>);
await foreach (var data in client.GetWeathersAsync("<partyId>", "<boundaryId>", "<extensionId>", "<weatherDataType>", "<granularity>"))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("partyId").ToString());
Console.WriteLine(result.GetProperty("boundaryId").ToString());
Console.WriteLine(result.GetProperty("extensionId").ToString());
Console.WriteLine(result.GetProperty("location").GetProperty("latitude").ToString());
Console.WriteLine(result.GetProperty("location").GetProperty("longitude").ToString());
Console.WriteLine(result.GetProperty("dateTime").ToString());
Console.WriteLine(result.GetProperty("extensionVersion").ToString());
Console.WriteLine(result.GetProperty("weatherDataType").ToString());
Console.WriteLine(result.GetProperty("granularity").ToString());
}
Este exemplo mostra como chamar GetWeathersAsync com todos os parâmetros e como analisar o resultado.
var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetWeatherClient(<2022-11-01-preview>);
await foreach (var data in client.GetWeathersAsync("<partyId>", "<boundaryId>", "<extensionId>", "<weatherDataType>", "<granularity>", DateTimeOffset.UtcNow, DateTimeOffset.UtcNow, 1234, "<skipToken>"))
{
JsonElement result = JsonDocument.Parse(data.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("partyId").ToString());
Console.WriteLine(result.GetProperty("boundaryId").ToString());
Console.WriteLine(result.GetProperty("extensionId").ToString());
Console.WriteLine(result.GetProperty("location").GetProperty("latitude").ToString());
Console.WriteLine(result.GetProperty("location").GetProperty("longitude").ToString());
Console.WriteLine(result.GetProperty("dateTime").ToString());
Console.WriteLine(result.GetProperty("unitSystemCode").ToString());
Console.WriteLine(result.GetProperty("extensionVersion").ToString());
Console.WriteLine(result.GetProperty("weatherDataType").ToString());
Console.WriteLine(result.GetProperty("granularity").ToString());
Console.WriteLine(result.GetProperty("cloudCover").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("cloudCover").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("dewPoint").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("dewPoint").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("growingDegreeDay").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("growingDegreeDay").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("precipitation").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("precipitation").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("pressure").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("pressure").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("relativeHumidity").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("relativeHumidity").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("soilMoisture").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("soilMoisture").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("soilTemperature").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("soilTemperature").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("temperature").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("temperature").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("visibility").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("visibility").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("wetBulbTemperature").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("wetBulbTemperature").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("windChill").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("windChill").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("windDirection").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("windDirection").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("windGust").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("windGust").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("windSpeed").GetProperty("unit").ToString());
Console.WriteLine(result.GetProperty("windSpeed").GetProperty("value").ToString());
Console.WriteLine(result.GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("eTag").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("modifiedDateTime").ToString());
Console.WriteLine(result.GetProperty("properties").GetProperty("<test>").ToString());
}
Comentários
Abaixo está o esquema JSON para um item na resposta paginável.
Corpo da resposta:
Esquema para WeatherDataListResponseValue
:
{
partyId: string, # Required. Party ID.
boundaryId: string, # Required. Boundary ID.
extensionId: string, # Required. ID of the weather extension.
location: {
latitude: number, # Required. Latitude of the location.
longitude: number, # Required. Longitude of the location.
}, # Required. Location model class.
dateTime: string (ISO 8601 Format), # Required. Date-time of the weather data, sample format: yyyy-MM-ddTHH:mm:ssZ.
unitSystemCode: string, # Optional. Unit System like US/SI etc.
extensionVersion: string, # Required. Version of the weather data extension.
weatherDataType: string, # Required. Type of weather data (forecast/historical).
granularity: string, # Required. Granularity of weather data (daily/hourly).
cloudCover: {
unit: string, # Optional. Data unit.
value: number, # Optional. Data value.
}, # Optional. Schema for storing measurement reading and unit.
dewPoint: Measure, # Optional. Schema for storing measurement reading and unit.
growingDegreeDay: Measure, # Optional. Schema for storing measurement reading and unit.
precipitation: Measure, # Optional. Schema for storing measurement reading and unit.
pressure: Measure, # Optional. Schema for storing measurement reading and unit.
relativeHumidity: Measure, # Optional. Schema for storing measurement reading and unit.
soilMoisture: Measure, # Optional. Schema for storing measurement reading and unit.
soilTemperature: Measure, # Optional. Schema for storing measurement reading and unit.
temperature: Measure, # Optional. Schema for storing measurement reading and unit.
visibility: Measure, # Optional. Schema for storing measurement reading and unit.
wetBulbTemperature: Measure, # Optional. Schema for storing measurement reading and unit.
windChill: Measure, # Optional. Schema for storing measurement reading and unit.
windDirection: Measure, # Optional. Schema for storing measurement reading and unit.
windGust: Measure, # Optional. Schema for storing measurement reading and unit.
windSpeed: Measure, # Optional. Schema for storing measurement reading and unit.
id: string, # Optional. Weather data ID.
eTag: string, # Optional. The ETag value to implement optimistic concurrency.
createdDateTime: string (ISO 8601 Format), # Optional. Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ.
modifiedDateTime: string (ISO 8601 Format), # Optional. Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ.
properties: Dictionary<string, any>, # Optional. A collection of key value pairs that belongs to the resource.
Each pair must not have a key greater than 50 characters
and must not have a value greater than 250 characters.
Note: A maximum of 25 key value pairs can be provided for a resource and only string and numeral values are supported.
}
Aplica-se a
Azure SDK for .NET