diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/Azure.AgriculturePlatform.sln b/sdk/agricultureplatform/Azure.AgriculturePlatform/Azure.AgriculturePlatform.sln new file mode 100644 index 000000000000..df9004d44743 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/Azure.AgriculturePlatform.sln @@ -0,0 +1,56 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29709.97 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Core.TestFramework", "..\..\core\Azure.Core.TestFramework\src\Azure.Core.TestFramework.csproj", "{ECC730C1-4AEA-420C-916A-66B19B79E4DC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AgriculturePlatform", "src\Azure.AgriculturePlatform.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.AgriculturePlatform.Tests", "tests\Azure.AgriculturePlatform.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ECC730C1-4AEA-420C-916A-66B19B79E4DC}.Release|Any CPU.Build.0 = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE} + EndGlobalSection +EndGlobal diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/CHANGELOG.md b/sdk/agricultureplatform/Azure.AgriculturePlatform/CHANGELOG.md new file mode 100644 index 000000000000..8b33f0fedccc --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/Directory.Build.props b/sdk/agricultureplatform/Azure.AgriculturePlatform/Directory.Build.props new file mode 100644 index 000000000000..63bd836ad44b --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/README.md b/sdk/agricultureplatform/Azure.AgriculturePlatform/README.md new file mode 100644 index 000000000000..3ab14fea1b97 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/README.md @@ -0,0 +1,107 @@ +# Azure.AgriculturePlatform client library for .NET + +Azure.AgriculturePlatform is a managed service that helps developers get secret simply and securely. + +Use the client library for to: + +* [Get secret](https://docs.microsoft.com/azure) + +[Source code][source_root] | [Package (NuGet)][package] | [API reference documentation][reference_docs] | [Product documentation][azconfig_docs] | [Samples][source_samples] + + [Source code](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/agricultureplatform/Azure.AgriculturePlatform/src) | [Package (NuGet)](https://www.nuget.org/packages) | [API reference documentation](https://azure.github.io/azure-sdk-for-net) | [Product documentation](https://docs.microsoft.com/azure) + +## Getting started + +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. + +### Install the package + +First, provide instruction for obtaining and installing the package or library. This section might include only a single line of code, like `dotnet add package package-name`, but should enable a developer to successfully install the package from NuGet, npm, or even cloning a GitHub repository. + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.AgriculturePlatform --prerelease +``` + +### Prerequisites + +Include a section after the install command that details any requirements that must be satisfied before a developer can [authenticate](#authenticate-the-client) and test all of the snippets in the [Examples](#examples) section. For example, for Cosmos DB: + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/) and [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API). In order to take advantage of the C# 8.0 syntax, it is recommended that you compile using the [.NET Core SDK](https://dotnet.microsoft.com/download) 3.0 or higher with a [language version](https://docs.microsoft.com/dotnet/csharp/language-reference/configure-language-version#override-a-default) of `latest`. It is also possible to compile with the .NET Core SDK 2.1.x using a language version of `preview`. + +### Authenticate the client + +If your library requires authentication for use, such as for Azure services, include instructions and example code needed for initializing and authenticating. + +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and initializing the client object. + +### Service API versions + +The client library targets the latest service API version by default. A client instance accepts an optional service API version parameter from its options to specify which API version service to communicate. + +#### Select a service API version + +You have the flexibility to explicitly select a supported service API version when instantiating a client by configuring its associated options. This ensures that the client can communicate with services using the specified API version. + +For example, + +```C# Snippet:CreateClientForSpecificApiVersion +Uri endpoint = new Uri(""); +DefaultAzureCredential credential = new DefaultAzureCredential(); +ClientOptions options = new ClientOptions(ClientOptions.ServiceVersion.) +var client = new Client(endpoint, credential, options); +``` + +When selecting an API version, it's important to verify that there are no breaking changes compared to the latest API version. If there are significant differences, API calls may fail due to incompatibility. + +Always ensure that the chosen API version is fully supported and operational for your specific use case and that it aligns with the service's versioning policy. + +## Key concepts + +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel free to use bulleted lists, tables, code blocks, or even diagrams for clarity. + +Include the *Thread safety* and *Additional concepts* sections below at the end of your *Key concepts* section. You may remove or add links depending on what your library makes use of: + +### Thread safety + +We guarantee that all client instance methods are thread-safe and independent of each other ([guideline](https://azure.github.io/azure-sdk/dotnet_introduction.html#dotnet-service-methods-thread-safety)). This ensures that the recommendation of reusing client instances is always safe, even across threads. + +### Additional concepts + +[Client options](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#configuring-service-clients-using-clientoptions) | +[Accessing the response](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#accessing-http-response-details-using-responset) | +[Long-running operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#consuming-long-running-operations-using-operationt) | +[Handling failures](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#reporting-errors-requestfailedexception) | +[Diagnostics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/Diagnostics.md) | +[Mocking](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/README.md#mocking) | +[Client lifetime](https://devblogs.microsoft.com/azure-sdk/lifetime-management-and-thread-safety-guarantees-of-azure-sdk-net-clients/) + + +## Examples + +You can familiarize yourself with different APIs using [Samples](https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/agricultureplatform/Azure.AgriculturePlatform/samples). + +## Troubleshooting + +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. + +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, provide guidance and examples for using retry or connection policies in the API. + +If the package or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. + +## Next steps + +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. +* If appropriate, point users to other packages that might be useful. +* If you think there's a good chance that developers might stumble across your package in error (because they're searching for specific functionality and mistakenly think the package provides that functionality), point them to the packages they might be looking for. + +## Contributing + +This is a template, but your SDK readme should include details on how to contribute code to the repo/package. + + +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization +[style-guide-cloud]: https://aka.ms/azsdk/cloud-style-guide + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-net/sdk/agricultureplatform/Azure.AgriculturePlatform/README.png) \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Azure.AgriculturePlatform.csproj b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Azure.AgriculturePlatform.csproj new file mode 100644 index 000000000000..3fd302b4f066 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Azure.AgriculturePlatform.csproj @@ -0,0 +1,20 @@ + + + This is the Azure.AgriculturePlatform client library for developing .NET applications with rich experience. + Azure SDK Code Generation Azure.AgriculturePlatform for Azure Data Plane + 1.0.0-beta.1 + Azure.AgriculturePlatform + $(RequiredTargetFrameworks) + true + + + + + + + + + + + + diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AcceptHeaderEnum.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AcceptHeaderEnum.cs new file mode 100644 index 000000000000..d3e39af982b0 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AcceptHeaderEnum.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AgriculturePlatform +{ + /// enum for request "accept" header. + public readonly partial struct AcceptHeaderEnum : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AcceptHeaderEnum(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string JsonValue = "application/json"; + private const string OctetStreamValue = "application/octet-stream"; + + /// application/json. + public static AcceptHeaderEnum Json { get; } = new AcceptHeaderEnum(JsonValue); + /// application/octet-stream. + public static AcceptHeaderEnum OctetStream { get; } = new AcceptHeaderEnum(OctetStreamValue); + /// Determines if two values are the same. + public static bool operator ==(AcceptHeaderEnum left, AcceptHeaderEnum right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AcceptHeaderEnum left, AcceptHeaderEnum right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AcceptHeaderEnum(string value) => new AcceptHeaderEnum(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AcceptHeaderEnum other && Equals(other); + /// + public bool Equals(AcceptHeaderEnum other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClient.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClient.cs new file mode 100644 index 000000000000..1212b3750c67 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClient.cs @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated client. + /// APIs documentation for Azure AgPlatform DataPlane Service. + public partial class AgriculturePlatformClient + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of AgriculturePlatformClient for mocking. + protected AgriculturePlatformClient() + { + } + + /// Initializes a new instance of AgriculturePlatformClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// or is null. + public AgriculturePlatformClient(Uri endpoint, AzureKeyCredential credential) : this(endpoint, credential, new AgriculturePlatformClientOptions()) + { + } + + /// Initializes a new instance of AgriculturePlatformClient. + /// The to use. + /// A credential used to authenticate to an Azure Service. + /// The options for configuring the client. + /// or is null. + public AgriculturePlatformClient(Uri endpoint, AzureKeyCredential credential, AgriculturePlatformClientOptions options) + { + Argument.AssertNotNull(endpoint, nameof(endpoint)); + Argument.AssertNotNull(credential, nameof(credential)); + options ??= new AgriculturePlatformClientOptions(); + + ClientDiagnostics = new ClientDiagnostics(options, true); + _keyCredential = credential; + _pipeline = HttpPipelineBuilder.Build(options, Array.Empty(), new HttpPipelinePolicy[] { new AzureKeyCredentialPolicy(_keyCredential, AuthorizationHeader) }, new ResponseClassifier()); + _endpoint = endpoint; + } + + /// Initializes a new instance of Catalogs. + /// The API version to use for this operation. + /// is null. + public virtual Catalogs GetCatalogsClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Catalogs(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Collections. + /// The API version to use for this operation. + /// is null. + public virtual Collections GetCollectionsClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Collections(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of File. + /// The API version to use for this operation. + /// is null. + public virtual File GetFileClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new File(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Items. + /// The API version to use for this operation. + /// is null. + public virtual Items GetItemsClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Items(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Satellite. + /// The API version to use for this operation. + /// is null. + public virtual Satellite GetSatelliteClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Satellite(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Schemas. + /// The API version to use for this operation. + /// is null. + public virtual Schemas GetSchemasClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Schemas(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Solutions. + /// The API version to use for this operation. + /// is null. + public virtual Solutions GetSolutionsClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Solutions(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + + /// Initializes a new instance of Weather. + /// The API version to use for this operation. + /// is null. + public virtual Weather GetWeatherClient(string apiVersion = "2024-11-01-preview") + { + Argument.AssertNotNull(apiVersion, nameof(apiVersion)); + + return new Weather(ClientDiagnostics, _pipeline, _keyCredential, _endpoint, apiVersion); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClientBuilderExtensions.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClientBuilderExtensions.cs new file mode 100644 index 000000000000..f11771de89cb --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClientBuilderExtensions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure; +using Azure.AgriculturePlatform; +using Azure.Core.Extensions; + +namespace Microsoft.Extensions.Azure +{ + /// Extension methods to add to client builder. + public static partial class AgriculturePlatformClientBuilderExtensions + { + /// Registers a instance. + /// The builder to register with. + /// The to use. + /// A credential used to authenticate to an Azure Service. + public static IAzureClientBuilder AddAgriculturePlatformClient(this TBuilder builder, Uri endpoint, AzureKeyCredential credential) + where TBuilder : IAzureClientFactoryBuilder + { + return builder.RegisterClientFactory((options) => new AgriculturePlatformClient(endpoint, credential, options)); + } + + /// Registers a instance. + /// The builder to register with. + /// The configuration values. + public static IAzureClientBuilder AddAgriculturePlatformClient(this TBuilder builder, TConfiguration configuration) + where TBuilder : IAzureClientFactoryBuilderWithConfiguration + { + return builder.RegisterClientFactory(configuration); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClientOptions.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClientOptions.cs new file mode 100644 index 000000000000..c025141f4905 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformClientOptions.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + /// Client options for AgriculturePlatformClient. + public partial class AgriculturePlatformClientOptions : ClientOptions + { + private const ServiceVersion LatestVersion = ServiceVersion.V2024_11_01_Preview; + + /// The version of the service to use. + public enum ServiceVersion + { + /// Service version "2024-11-01-preview". + V2024_11_01_Preview = 1, + } + + internal string Version { get; } + + /// Initializes new instance of AgriculturePlatformClientOptions. + public AgriculturePlatformClientOptions(ServiceVersion version = LatestVersion) + { + Version = version switch + { + ServiceVersion.V2024_11_01_Preview => "2024-11-01-preview", + _ => throw new NotSupportedException() + }; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformModelFactory.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformModelFactory.cs new file mode 100644 index 000000000000..c49fccc7ffff --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AgriculturePlatformModelFactory.cs @@ -0,0 +1,658 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + /// Model factory for models. + public static partial class AgriculturePlatformModelFactory + { + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Id of the Catalog. + /// A new instance for mocking. + public static Catalog Catalog(IEnumerable links = null, string eTag = null, string status = null, DateTimeOffset? createdDateTime = null, DateTimeOffset? modifiedDateTime = null, string source = null, string name = null, string description = null, string createdBy = null, string modifiedBy = null, IDictionary properties = null, string id = null) + { + links ??= new List(); + properties ??= new Dictionary(); + + return new Catalog( + links?.ToList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties, + id, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Schema Foreign Key. + /// Id of the Catalog. + /// Unique resource ID. + /// A new instance for mocking. + public static Collection Collection(IEnumerable links = null, string eTag = null, string status = null, DateTimeOffset? createdDateTime = null, DateTimeOffset? modifiedDateTime = null, string source = null, string name = null, string description = null, string createdBy = null, string modifiedBy = null, IDictionary properties = null, string schemaId = null, string catalogId = null, string id = null) + { + links ??= new List(); + properties ??= new Dictionary(); + + return new Collection( + links?.ToList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties, + schemaId, + catalogId, + id, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// FilePath. + /// A new instance for mocking. + public static FileModel FileModel(string filePath = null) + { + return new FileModel(filePath, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Schema for records under the dataset. + /// OwnerItemId. + /// CatalogId. + /// CollectionId. + /// Assets. + /// Unique resource ID. + /// A new instance for mocking. + public static ItemResponse ItemResponse(IEnumerable links = null, string eTag = null, string status = null, DateTimeOffset? createdDateTime = null, DateTimeOffset? modifiedDateTime = null, string source = null, string name = null, string description = null, string createdBy = null, string modifiedBy = null, IReadOnlyDictionary properties = null, IReadOnlyDictionary data = null, string ownerItemId = null, string catalogId = null, string collectionId = null, IEnumerable assets = null, string id = null) + { + links ??= new List(); + properties ??= new Dictionary(); + data ??= new Dictionary(); + assets ??= new List(); + + return new ItemResponse( + links?.ToList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties, + data, + ownerItemId, + catalogId, + collectionId, + assets?.ToList(), + id, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Schema for records under the dataset. + /// Owner Item Ids of the resource. + /// Id of the Catalog resource. + /// Id of the Collection resource. + /// Assets. + /// Id of the Item. + /// A new instance for mocking. + public static Item Item(IEnumerable links = null, string eTag = null, string status = null, DateTimeOffset? createdDateTime = null, DateTimeOffset? modifiedDateTime = null, string source = null, string name = null, string description = null, string createdBy = null, string modifiedBy = null, IDictionary properties = null, IDictionary data = null, string ownerItemId = null, string catalogId = null, string collectionId = null, IEnumerable assets = null, string id = null) + { + links ??= new List(); + properties ??= new Dictionary(); + data ??= new Dictionary(); + assets ??= new List(); + + return new Item( + links?.ToList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties, + data, + ownerItemId, + catalogId, + collectionId, + assets?.ToList(), + id, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// List of Items. + /// Skip token for getting next set of results. + /// + /// URL to do the POST request with same filters, + /// to get next set of items. + /// + /// A new instance for mocking. + public static ItemListResponse ItemListResponse(IEnumerable value = null, string skipToken = null, string nextLink = null) + { + value ??= new List(); + + return new ItemListResponse(value?.ToList(), skipToken, nextLink, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// ClientId associated with the provider. + /// Properties of the key vault. + /// A new instance for mocking. + public static OauthClientCredentials OauthClientCredentials(string clientId = null, KeyVaultProperties clientSecret = null) + { + return new OauthClientCredentials(AuthCredentialsKind.OAuthClientCredentials, serializedAdditionalRawData: null, clientId, clientSecret); + } + + /// Initializes a new instance of . + /// Properties of the key vault. + /// A new instance for mocking. + public static ApiKeyAuthCredentials ApiKeyAuthCredentials(KeyVaultProperties apiKey = null) + { + return new ApiKeyAuthCredentials(AuthCredentialsKind.ApiKeyAuthCredentials, serializedAdditionalRawData: null, apiKey); + } + + /// Initializes a new instance of . + /// Value. + /// A new instance for mocking. + public static SatelliteFetchResponse SatelliteFetchResponse(IEnumerable value = null) + { + value ??= new List(); + + return new SatelliteFetchResponse(value?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Start Date. + /// Provider of satellite data. Available Value: SentinelHub. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Feature Id. + /// ImageFiles. + /// ItemUri. + /// Id. + /// A new instance for mocking. + public static SatelliteFetchData SatelliteFetchData(DateTimeOffset? dateTime = null, string provider = null, string providerCollectionId = null, string featureId = null, IEnumerable imageFiles = null, string itemUri = null, string id = null) + { + imageFiles ??= new List(); + + return new SatelliteFetchData( + dateTime, + provider, + providerCollectionId, + featureId, + imageFiles?.ToList(), + itemUri, + id, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// ADLS path of the image file. + /// Name of the image file. + /// Supported image formats for scene resource. + /// Resolution of image file in meters. + /// A new instance for mocking. + public static ImageFile ImageFile(string filePath = null, string name = null, ImageFormat? imageFormat = null, double? resolution = null) + { + return new ImageFile(filePath, name, imageFormat, resolution, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// List of items. + /// + /// URL to do the POST request with same filters, + /// to get next set of items. + /// + /// A new instance for mocking. + public static SearchFeaturesResponse SearchFeaturesResponse(IEnumerable features = null, string nextLink = null) + { + features ??= new List(); + + return new SearchFeaturesResponse(features?.ToList(), nextLink, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The STAC version the Stac Item implements. + /// A list of extensions the Stac Item implements. + /// Provider identifier. Globally unique ID by Data provider. + /// Type of the GeoJSON Object. It's value is always Feature. + /// + /// Defines the full footprint of the asset represented by this item. + /// Its a GeoJSON geometry. + /// + /// Bounding box of the item. + /// A dictionary of additional metadata for the item. + /// List of link objects to resources and related URLs. + /// Dictionary of asset objects, each with a unique key. + /// The id of the STAC Collection this Stac Item references. + /// A new instance for mocking. + public static StacItem StacItem(string stacVersion = null, IEnumerable stacExtensions = null, string id = null, string type = null, BinaryData geometry = null, IEnumerable bbox = null, BinaryData properties = null, IEnumerable links = null, IReadOnlyDictionary assets = null, string providerCollectionId = null) + { + stacExtensions ??= new List(); + bbox ??= new List(); + links ??= new List(); + assets ??= new Dictionary(); + + return new StacItem( + stacVersion, + stacExtensions?.ToList(), + id, + type, + geometry, + bbox?.ToList(), + properties, + links?.ToList(), + assets, + providerCollectionId, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The HREF of the link. + /// The relation type of the link. + /// The type of the link. Optional. + /// The title of the link. Optional. + /// A new instance for mocking. + public static StacLink StacLink(string href = null, string rel = null, string type = null, string title = null) + { + return new StacLink(href, rel, type, title, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// The HREF of the asset. + /// The title of the asset. + /// The description of the asset. + /// The type of the asset. + /// The roles of the asset. + /// A new instance for mocking. + public static StacAsset StacAsset(string href = null, string title = null, string description = null, string type = null, IEnumerable roles = null) + { + roles ??= new List(); + + return new StacAsset( + href, + title, + description, + type, + roles?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Dependent Collections. + /// Schema. + /// Id of the Schema. + /// A new instance for mocking. + public static Schema Schema(IEnumerable links = null, string eTag = null, string status = null, DateTimeOffset? createdDateTime = null, DateTimeOffset? modifiedDateTime = null, string source = null, string name = null, string description = null, string createdBy = null, string modifiedBy = null, IDictionary properties = null, IEnumerable dependentCollections = null, IDictionary schemaModel = null, string id = null) + { + links ??= new List(); + properties ??= new Dictionary(); + dependentCollections ??= new List(); + schemaModel ??= new Dictionary(); + + return new Schema( + links?.ToList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties, + dependentCollections?.ToList(), + schemaModel, + id, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Catalog Id. + /// Collection Id. + /// A new instance for mocking. + public static CatalogCollection CatalogCollection(string catalogId = null, string collectionId = null) + { + return new CatalogCollection(catalogId, collectionId, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Id. + /// Message. + /// Status. + /// JobCreatedDateTime. + /// JobLastActionDateTime. + /// E2eid. + /// SamplePartnerRequestBody. + /// A new instance for mocking. + public static SamplePartnerResponse SamplePartnerResponse(string id = null, string message = null, string status = null, DateTimeOffset? jobCreatedDateTime = null, DateTimeOffset? jobLastActionDateTime = null, string e2Eid = null, SamplePartnerRequestBody partnerRequestBody = null) + { + return new SamplePartnerResponse( + id, + message, + status, + jobCreatedDateTime, + jobLastActionDateTime, + e2Eid, + partnerRequestBody, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// SolutionId. + /// PartyId. + /// GddStartDate. + /// GddEndDate. + /// ResourceId. + /// ResourceType. + /// Crop. + /// TemperatureUnit. + /// Method. + /// A new instance for mocking. + public static SamplePartnerRequestBody SamplePartnerRequestBody(string solutionId = null, string partyId = null, DateTimeOffset? gddStartDate = null, DateTimeOffset? gddEndDate = null, string resourceId = null, string resourceType = null, string crop = null, string temperatureUnit = null, string method = null) + { + return new SamplePartnerRequestBody( + solutionId, + partyId, + gddStartDate, + gddEndDate, + resourceId, + resourceType, + crop, + temperatureUnit, + method, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Schema of Weather Metadata. + /// Indicates a Succeeded, Failed, or PartiallySucceeded response. + /// List of weather data for all the weather locations. + /// Model for errors encountered for all failed locations. + /// A new instance for mocking. + public static WeatherResponse WeatherResponse(WeatherMetadata weatherMetadata = null, string status = null, IEnumerable locations = null, WeatherDataErrors errors = null) + { + locations ??= new List(); + + return new WeatherResponse(weatherMetadata, status, locations?.ToList(), errors, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Weather provider name. + /// Provider's api name to which request is to be made. + /// + /// Language (IETF BCP 47 language tag) in which search results should be returned + /// by the data provider. Examples: 'en-US', 'es', 'es-MX', 'fr-FR'. + /// + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + /// Type of weather data (forecast/historical). + /// A new instance for mocking. + public static WeatherMetadata WeatherMetadata(string providerName = null, string providerApiName = null, string language = null, string units = null, string weatherDataType = null) + { + return new WeatherMetadata( + providerName, + providerApiName, + language, + units, + weatherDataType, + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Schema of Location data. + /// Request Completion Time in Utc of the location. + /// Date-time when resource was last requested, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Schema of weather data. + /// A new instance for mocking. + public static WeatherLocationData WeatherLocationData(WeatherLocation location = null, string requestCompletionTime = null, DateTimeOffset? lastRefreshedDateTime = null, WeatherData data = null) + { + return new WeatherLocationData(location, requestCompletionTime, lastRefreshedDateTime, data, serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// + /// 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 100 key value pairs can be provided for + /// a resource and only string and numeral values are supported. + /// + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Day of week. + /// + /// This data field indicates whether it is daytime or nighttime based on the Local + /// Apparent Time of the location. + /// + /// Expiration time in Utc format. + /// + /// This number is the key to the weather icon lookup. The data field shows the + /// icon number that is matched to represent the observed weather conditions. + /// + /// Code representing full set sensible weather. + /// Indicates whether there is precipitation or not. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// + /// The UV Index Description which complements the UV Index value by providing an + /// associated level of risk of skin damage due to exposure (-2 = Not Available, -1 + /// = No Report, 0 to 2 = Low, 3 to 5 = Moderate, 6 to 7 = High, 8 to 10 = Very + /// High, 11 to 16 = Extreme). + /// + /// Hourly maximum UV index. + /// Time forecast is valid in local apparent time. + /// Time forecast is valid in Utc format. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Hourly sensible weather phrase containing longer description. + /// Hourly sensible weather phrase containing short description. + /// A new instance for mocking. + public static WeatherData WeatherData(IReadOnlyDictionary additionalAttributes = null, Measures wetBulbTemperature = null, Measures cloudCover = null, IEnumerable dayOfWeek = null, IEnumerable dayOrNight = null, IEnumerable expirationTime = null, IEnumerable iconCode = null, IEnumerable iconCodeExtend = null, IEnumerable hasPrecipitation = null, Measures pressureMeanSeaLevel = null, Measures relativeHumidity = null, Measures temperature = null, Measures temperatureDewPoint = null, Measures temperatureFeelsLike = null, Measures temperatureHeatIndex = null, Measures temperatureWindChill = null, IEnumerable uvDescription = null, IEnumerable uvIndex = null, IEnumerable validTimeLocal = null, IEnumerable validTime = null, Measures visibility = null, Measures windDirection = null, Measures windGust = null, Measures windSpeed = null, IEnumerable wxPhraseLong = null, IEnumerable wxPhraseShort = null) + { + additionalAttributes ??= new Dictionary(); + dayOfWeek ??= new List(); + dayOrNight ??= new List(); + expirationTime ??= new List(); + iconCode ??= new List(); + iconCodeExtend ??= new List(); + hasPrecipitation ??= new List(); + uvDescription ??= new List(); + uvIndex ??= new List(); + validTimeLocal ??= new List(); + validTime ??= new List(); + wxPhraseLong ??= new List(); + wxPhraseShort ??= new List(); + + return new WeatherData( + additionalAttributes, + wetBulbTemperature, + cloudCover, + dayOfWeek?.ToList(), + dayOrNight?.ToList(), + expirationTime?.ToList(), + iconCode?.ToList(), + iconCodeExtend?.ToList(), + hasPrecipitation?.ToList(), + pressureMeanSeaLevel, + relativeHumidity, + temperature, + temperatureDewPoint, + temperatureFeelsLike, + temperatureHeatIndex, + temperatureWindChill, + uvDescription?.ToList(), + uvIndex?.ToList(), + validTimeLocal?.ToList(), + validTime?.ToList(), + visibility, + windDirection, + windGust, + windSpeed, + wxPhraseLong?.ToList(), + wxPhraseShort?.ToList(), + serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Data unit. + /// Data values. + /// A new instance for mocking. + public static Measures Measures(string unit = null, IEnumerable value = null) + { + value ??= new List(); + + return new Measures(unit, value?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// List of errors encountered for all failed locations. + /// A new instance for mocking. + public static WeatherDataErrors WeatherDataErrors(IEnumerable locations = null) + { + locations ??= new List(); + + return new WeatherDataErrors(locations?.ToList(), serializedAdditionalRawData: null); + } + + /// Initializes a new instance of . + /// Schema of Location data. + /// Status code returned by data provider. + /// Description of the error. + /// + /// Flag suggesting if retry attempt with same request body should be made to fetch + /// required data. + /// + /// A new instance for mocking. + public static ErrorForLocation ErrorForLocation(WeatherLocation location = null, int? code = null, string description = null, bool? retryable = null) + { + return new ErrorForLocation(location, code, description, retryable, serializedAdditionalRawData: null); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ApiKeyAuthCredentials.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ApiKeyAuthCredentials.Serialization.cs new file mode 100644 index 000000000000..a6b423a601f3 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ApiKeyAuthCredentials.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class ApiKeyAuthCredentials : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApiKeyAuthCredentials)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("apiKey"u8); + writer.WriteObjectValue(ApiKey, options); + } + + ApiKeyAuthCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ApiKeyAuthCredentials)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeApiKeyAuthCredentials(document.RootElement, options); + } + + internal static ApiKeyAuthCredentials DeserializeApiKeyAuthCredentials(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + KeyVaultProperties apiKey = default; + AuthCredentialsKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("apiKey"u8)) + { + apiKey = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value, options); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new AuthCredentialsKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ApiKeyAuthCredentials(kind, serializedAdditionalRawData, apiKey); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ApiKeyAuthCredentials)} does not support writing '{options.Format}' format."); + } + } + + ApiKeyAuthCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApiKeyAuthCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ApiKeyAuthCredentials)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new ApiKeyAuthCredentials FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeApiKeyAuthCredentials(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ApiKeyAuthCredentials.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ApiKeyAuthCredentials.cs new file mode 100644 index 000000000000..d4474c415a17 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ApiKeyAuthCredentials.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Api Key Auth Credentials class for API Key based Auth. + public partial class ApiKeyAuthCredentials : AuthCredentials + { + /// Initializes a new instance of . + /// Properties of the key vault. + /// is null. + public ApiKeyAuthCredentials(KeyVaultProperties apiKey) + { + Argument.AssertNotNull(apiKey, nameof(apiKey)); + + Kind = AuthCredentialsKind.ApiKeyAuthCredentials; + ApiKey = apiKey; + } + + /// Initializes a new instance of . + /// Enum for different types of AuthCredentials supported. + /// Keeps track of any properties unknown to the library. + /// Properties of the key vault. + internal ApiKeyAuthCredentials(AuthCredentialsKind kind, IDictionary serializedAdditionalRawData, KeyVaultProperties apiKey) : base(kind, serializedAdditionalRawData) + { + ApiKey = apiKey; + } + + /// Initializes a new instance of for deserialization. + internal ApiKeyAuthCredentials() + { + } + + /// Properties of the key vault. + public KeyVaultProperties ApiKey { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Asset.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Asset.Serialization.cs new file mode 100644 index 000000000000..9d772bf63f12 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Asset.Serialization.cs @@ -0,0 +1,171 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Asset : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Asset)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Href)) + { + writer.WritePropertyName("href"u8); + writer.WriteStringValue(Href); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Asset IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Asset)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAsset(document.RootElement, options); + } + + internal static Asset DeserializeAsset(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DataFormat? type = default; + string name = default; + string href = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new DataFormat(property.Value.GetString()); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("href"u8)) + { + href = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Asset(type, name, href, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Asset)} does not support writing '{options.Format}' format."); + } + } + + Asset IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAsset(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Asset)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Asset FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAsset(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Asset.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Asset.cs new file mode 100644 index 000000000000..c5e2f63e5878 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Asset.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Asset. + public partial class Asset + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Asset() + { + } + + /// Initializes a new instance of . + /// Type of dataset. + /// Name. + /// Href. + /// Keeps track of any properties unknown to the library. + internal Asset(DataFormat? type, string name, string href, IDictionary serializedAdditionalRawData) + { + Type = type; + Name = name; + Href = href; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of dataset. + public DataFormat? Type { get; set; } + /// Name. + public string Name { get; set; } + /// Href. + public string Href { get; set; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentials.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentials.Serialization.cs new file mode 100644 index 000000000000..666e07045adf --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentials.Serialization.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + [PersistableModelProxy(typeof(UnknownAuthCredentials))] + public partial class AuthCredentials : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthCredentials)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("kind"u8); + writer.WriteStringValue(Kind.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + AuthCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthCredentials)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAuthCredentials(document.RootElement, options); + } + + internal static AuthCredentials DeserializeAuthCredentials(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("kind", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "ApiKeyAuthCredentials": return ApiKeyAuthCredentials.DeserializeApiKeyAuthCredentials(element, options); + case "OAuthClientCredentials": return OauthClientCredentials.DeserializeOauthClientCredentials(element, options); + } + } + return UnknownAuthCredentials.DeserializeUnknownAuthCredentials(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AuthCredentials)} does not support writing '{options.Format}' format."); + } + } + + AuthCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAuthCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AuthCredentials)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static AuthCredentials FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAuthCredentials(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentials.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentials.cs new file mode 100644 index 000000000000..16a3e4d56a64 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentials.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// + /// AuthCredentials abstract base class for Auth Purpose. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include and . + /// + public abstract partial class AuthCredentials + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected AuthCredentials() + { + } + + /// Initializes a new instance of . + /// Enum for different types of AuthCredentials supported. + /// Keeps track of any properties unknown to the library. + internal AuthCredentials(AuthCredentialsKind kind, IDictionary serializedAdditionalRawData) + { + Kind = kind; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Enum for different types of AuthCredentials supported. + internal AuthCredentialsKind Kind { get; set; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentialsKind.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentialsKind.cs new file mode 100644 index 000000000000..9115d709c947 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/AuthCredentialsKind.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AgriculturePlatform +{ + /// Enum for different types of AuthCredentials supported. + internal readonly partial struct AuthCredentialsKind : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public AuthCredentialsKind(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string OAuthClientCredentialsValue = "OAuthClientCredentials"; + private const string ApiKeyAuthCredentialsValue = "ApiKeyAuthCredentials"; + + /// OAuthClientCredentials. + public static AuthCredentialsKind OAuthClientCredentials { get; } = new AuthCredentialsKind(OAuthClientCredentialsValue); + /// ApiKeyAuthCredentials. + public static AuthCredentialsKind ApiKeyAuthCredentials { get; } = new AuthCredentialsKind(ApiKeyAuthCredentialsValue); + /// Determines if two values are the same. + public static bool operator ==(AuthCredentialsKind left, AuthCredentialsKind right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(AuthCredentialsKind left, AuthCredentialsKind right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator AuthCredentialsKind(string value) => new AuthCredentialsKind(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is AuthCredentialsKind other && Equals(other); + /// + public bool Equals(AuthCredentialsKind other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CancelJobRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CancelJobRequest.Serialization.cs new file mode 100644 index 000000000000..0c2cff172e8f --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CancelJobRequest.Serialization.cs @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class CancelJobRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CancelJobRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + writer.WritePropertyName("requestPath"u8); + writer.WriteStringValue(RequestPath); + writer.WritePropertyName("partnerRequestBody"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestBody) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + writer.WritePropertyName("partnerRequestHeaders"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestHeaders) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CancelJobRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CancelJobRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCancelJobRequest(document.RootElement, options); + } + + internal static CancelJobRequest DeserializeCancelJobRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + string requestPath = default; + IReadOnlyDictionary partnerRequestBody = default; + IReadOnlyDictionary partnerRequestHeaders = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("solutionId"u8)) + { + solutionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestPath"u8)) + { + requestPath = property.Value.GetString(); + continue; + } + if (property.NameEquals("partnerRequestBody"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestBody = dictionary; + continue; + } + if (property.NameEquals("partnerRequestHeaders"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestHeaders = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CancelJobRequest(solutionId, requestPath, partnerRequestBody, partnerRequestHeaders, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CancelJobRequest)} does not support writing '{options.Format}' format."); + } + } + + CancelJobRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCancelJobRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CancelJobRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CancelJobRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCancelJobRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CancelJobRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CancelJobRequest.cs new file mode 100644 index 000000000000..2d6b6c3e8857 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CancelJobRequest.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The CancelJobRequest. + internal partial class CancelJobRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// , , or is null. + internal CancelJobRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + } + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Keeps track of any properties unknown to the library. + internal CancelJobRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IDictionary serializedAdditionalRawData) + { + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CancelJobRequest() + { + } + + /// SolutionId. + public string SolutionId { get; } + /// RequestPath. + public string RequestPath { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestBody { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestHeaders { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalog.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalog.Serialization.cs new file mode 100644 index 000000000000..ae86cc834e57 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalog.Serialization.cs @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Catalog : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Catalog)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Links)) + { + writer.WritePropertyName("links"u8); + writer.WriteStartArray(); + foreach (var item in Links) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("eTag"u8); + writer.WriteStringValue(ETag); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedDateTime)) + { + writer.WritePropertyName("modifiedDateTime"u8); + writer.WriteStringValue(ModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedBy)) + { + writer.WritePropertyName("modifiedBy"u8); + writer.WriteStringValue(ModifiedBy); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Catalog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Catalog)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCatalog(document.RootElement, options); + } + + internal static Catalog DeserializeCatalog(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList links = default; + string eTag = default; + string status = default; + DateTimeOffset? createdDateTime = default; + DateTimeOffset? modifiedDateTime = default; + string source = default; + string name = default; + string description = default; + string createdBy = default; + string modifiedBy = default; + IDictionary properties = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("links"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Link.DeserializeLink(item, options)); + } + links = array; + continue; + } + if (property.NameEquals("eTag"u8)) + { + eTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("modifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedBy"u8)) + { + modifiedBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + properties = dictionary; + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Catalog( + links ?? new ChangeTrackingList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties ?? new ChangeTrackingDictionary(), + id, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Catalog)} does not support writing '{options.Format}' format."); + } + } + + Catalog IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCatalog(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Catalog)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Catalog FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCatalog(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalog.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalog.cs new file mode 100644 index 000000000000..3951e3c52382 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalog.cs @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Catalog. + public partial class Catalog + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Catalog() + { + Links = new ChangeTrackingList(); + Properties = new ChangeTrackingDictionary(); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Id of the Catalog. + /// Keeps track of any properties unknown to the library. + internal Catalog(IList links, string eTag, string status, DateTimeOffset? createdDateTime, DateTimeOffset? modifiedDateTime, string source, string name, string description, string createdBy, string modifiedBy, IDictionary properties, string id, IDictionary serializedAdditionalRawData) + { + Links = links; + ETag = eTag; + Status = status; + CreatedDateTime = createdDateTime; + ModifiedDateTime = modifiedDateTime; + Source = source; + Name = name; + Description = description; + CreatedBy = createdBy; + ModifiedBy = modifiedBy; + Properties = properties; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Links for referencing other objects. + public IList Links { get; } + /// The ETag value to implement optimistic concurrency. + public string ETag { get; } + /// Status of the resource. + public string Status { get; set; } + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? CreatedDateTime { get; } + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? ModifiedDateTime { get; } + /// Source of the resource. + public string Source { get; set; } + /// Name to identify resource. + public string Name { get; set; } + /// Textual description of the resource. + public string Description { get; set; } + /// Created by user/tenant id. + public string CreatedBy { get; } + /// Modified by user/tenant id. + public string ModifiedBy { get; } + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary Properties { get; } + /// Id of the Catalog. + public string Id { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CatalogCollection.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CatalogCollection.Serialization.cs new file mode 100644 index 000000000000..66d046e48ce2 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CatalogCollection.Serialization.cs @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class CatalogCollection : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CatalogCollection)} does not support writing '{format}' format."); + } + + if (options.Format != "W" && Optional.IsDefined(CatalogId)) + { + writer.WritePropertyName("catalogId"u8); + writer.WriteStringValue(CatalogId); + } + if (options.Format != "W" && Optional.IsDefined(CollectionId)) + { + writer.WritePropertyName("collectionId"u8); + writer.WriteStringValue(CollectionId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CatalogCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CatalogCollection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCatalogCollection(document.RootElement, options); + } + + internal static CatalogCollection DeserializeCatalogCollection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string catalogId = default; + string collectionId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("catalogId"u8)) + { + catalogId = property.Value.GetString(); + continue; + } + if (property.NameEquals("collectionId"u8)) + { + collectionId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CatalogCollection(catalogId, collectionId, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CatalogCollection)} does not support writing '{options.Format}' format."); + } + } + + CatalogCollection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCatalogCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CatalogCollection)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CatalogCollection FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCatalogCollection(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CatalogCollection.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CatalogCollection.cs new file mode 100644 index 000000000000..0b0b207b24a3 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CatalogCollection.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema for storing catalog and collection id. + public partial class CatalogCollection + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal CatalogCollection() + { + } + + /// Initializes a new instance of . + /// Catalog Id. + /// Collection Id. + /// Keeps track of any properties unknown to the library. + internal CatalogCollection(string catalogId, string collectionId, IDictionary serializedAdditionalRawData) + { + CatalogId = catalogId; + CollectionId = collectionId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Catalog Id. + public string CatalogId { get; } + /// Collection Id. + public string CollectionId { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalogs.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalogs.cs new file mode 100644 index 000000000000..86e7458ab614 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Catalogs.cs @@ -0,0 +1,592 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The Catalogs sub-client. + public partial class Catalogs + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Catalogs for mocking. + protected Catalogs() + { + } + + /// Initializes a new instance of Catalogs. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal Catalogs(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Gets a specified Catalog resource. + /// Id of the Catalog. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetCatalogAsync(string catalogId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetCatalogAsync(catalogId, context).ConfigureAwait(false); + return Response.FromValue(Catalog.FromResponse(response), response); + } + + /// Gets a specified Catalog resource. + /// Id of the Catalog. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetCatalog(string catalogId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetCatalog(catalogId, context); + return Response.FromValue(Catalog.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a specified Catalog resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetCatalogAsync(string catalogId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + using var scope = ClientDiagnostics.CreateScope("Catalogs.GetCatalog"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCatalogRequest(catalogId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a specified Catalog resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetCatalog(string catalogId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + using var scope = ClientDiagnostics.CreateScope("Catalogs.GetCatalog"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCatalogRequest(catalogId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Catalog resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAsync(string catalogId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Catalogs.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(catalogId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Catalog resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdate(string catalogId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Catalogs.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(catalogId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Catalog for given Catalog id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteAsync(string catalogId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + using var scope = ClientDiagnostics.CreateScope("Catalogs.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(catalogId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Catalog for given Catalog id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Delete(string catalogId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + using var scope = ClientDiagnostics.CreateScope("Catalogs.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(catalogId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Returns a paginated list of Catalog resources. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetCatalogsAsync(IEnumerable names = null, IEnumerable propertyFilters = null, IEnumerable statuses = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCatalogsRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCatalogsNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Catalog.DeserializeCatalog(e), ClientDiagnostics, _pipeline, "Catalogs.GetCatalogs", "value", "nextLink", context); + } + + /// Returns a paginated list of Catalog resources. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// + public virtual Pageable GetCatalogs(IEnumerable names = null, IEnumerable propertyFilters = null, IEnumerable statuses = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCatalogsRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCatalogsNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Catalog.DeserializeCatalog(e), ClientDiagnostics, _pipeline, "Catalogs.GetCatalogs", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Returns a paginated list of Catalog resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetCatalogsAsync(IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCatalogsRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCatalogsNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Catalogs.GetCatalogs", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Returns a paginated list of Catalog resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetCatalogs(IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCatalogsRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCatalogsNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Catalogs.GetCatalogs", "value", "nextLink", context); + } + + internal HttpMessage CreateGetCatalogsRequest(IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (names != null && !(names is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + foreach (var param in names) + { + uri.AppendQuery("names", param, true); + } + } + if (propertyFilters != null && !(propertyFilters is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + foreach (var param in propertyFilters) + { + uri.AppendQuery("propertyFilters", param, true); + } + } + if (statuses != null && !(statuses is ChangeTrackingList changeTrackingList1 && changeTrackingList1.IsUndefined)) + { + foreach (var param in statuses) + { + uri.AppendQuery("statuses", param, true); + } + } + if (ids != null && !(ids is ChangeTrackingList changeTrackingList2 && changeTrackingList2.IsUndefined)) + { + foreach (var param in ids) + { + uri.AppendQuery("ids", param, true); + } + } + if (minCreatedDateTime != null) + { + uri.AppendQuery("minCreatedDateTime", minCreatedDateTime.Value, "O", true); + } + if (maxCreatedDateTime != null) + { + uri.AppendQuery("maxCreatedDateTime", maxCreatedDateTime.Value, "O", true); + } + if (minLastModifiedDateTime != null) + { + uri.AppendQuery("minLastModifiedDateTime", minLastModifiedDateTime.Value, "O", true); + } + if (maxLastModifiedDateTime != null) + { + uri.AppendQuery("maxLastModifiedDateTime", maxLastModifiedDateTime.Value, "O", true); + } + if (maxPageSize != null) + { + uri.AppendQuery("maxPageSize", maxPageSize.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetCatalogRequest(string catalogId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string catalogId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(string catalogId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetCatalogsNextPageRequest(string nextLink, IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collection.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collection.Serialization.cs new file mode 100644 index 000000000000..2abb9f1dfc82 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collection.Serialization.cs @@ -0,0 +1,356 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Collection : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Collection)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Links)) + { + writer.WritePropertyName("links"u8); + writer.WriteStartArray(); + foreach (var item in Links) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("eTag"u8); + writer.WriteStringValue(ETag); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedDateTime)) + { + writer.WritePropertyName("modifiedDateTime"u8); + writer.WriteStringValue(ModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedBy)) + { + writer.WritePropertyName("modifiedBy"u8); + writer.WriteStringValue(ModifiedBy); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + writer.WritePropertyName("schemaId"u8); + writer.WriteStringValue(SchemaId); + if (options.Format != "W" && Optional.IsDefined(CatalogId)) + { + writer.WritePropertyName("catalogId"u8); + writer.WriteStringValue(CatalogId); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Collection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Collection)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCollection(document.RootElement, options); + } + + internal static Collection DeserializeCollection(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList links = default; + string eTag = default; + string status = default; + DateTimeOffset? createdDateTime = default; + DateTimeOffset? modifiedDateTime = default; + string source = default; + string name = default; + string description = default; + string createdBy = default; + string modifiedBy = default; + IDictionary properties = default; + string schemaId = default; + string catalogId = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("links"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Link.DeserializeLink(item, options)); + } + links = array; + continue; + } + if (property.NameEquals("eTag"u8)) + { + eTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("modifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedBy"u8)) + { + modifiedBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + properties = dictionary; + continue; + } + if (property.NameEquals("schemaId"u8)) + { + schemaId = property.Value.GetString(); + continue; + } + if (property.NameEquals("catalogId"u8)) + { + catalogId = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Collection( + links ?? new ChangeTrackingList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties ?? new ChangeTrackingDictionary(), + schemaId, + catalogId, + id, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Collection)} does not support writing '{options.Format}' format."); + } + } + + Collection IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCollection(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Collection)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Collection FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCollection(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collection.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collection.cs new file mode 100644 index 000000000000..9ed12a02997d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collection.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Collection. + public partial class Collection + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Schema Foreign Key. + /// is null. + public Collection(string schemaId) + { + Argument.AssertNotNull(schemaId, nameof(schemaId)); + + Links = new ChangeTrackingList(); + Properties = new ChangeTrackingDictionary(); + SchemaId = schemaId; + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Schema Foreign Key. + /// Id of the Catalog. + /// Unique resource ID. + /// Keeps track of any properties unknown to the library. + internal Collection(IList links, string eTag, string status, DateTimeOffset? createdDateTime, DateTimeOffset? modifiedDateTime, string source, string name, string description, string createdBy, string modifiedBy, IDictionary properties, string schemaId, string catalogId, string id, IDictionary serializedAdditionalRawData) + { + Links = links; + ETag = eTag; + Status = status; + CreatedDateTime = createdDateTime; + ModifiedDateTime = modifiedDateTime; + Source = source; + Name = name; + Description = description; + CreatedBy = createdBy; + ModifiedBy = modifiedBy; + Properties = properties; + SchemaId = schemaId; + CatalogId = catalogId; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Collection() + { + } + + /// Links for referencing other objects. + public IList Links { get; } + /// The ETag value to implement optimistic concurrency. + public string ETag { get; } + /// Status of the resource. + public string Status { get; set; } + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? CreatedDateTime { get; } + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? ModifiedDateTime { get; } + /// Source of the resource. + public string Source { get; set; } + /// Name to identify resource. + public string Name { get; set; } + /// Textual description of the resource. + public string Description { get; set; } + /// Created by user/tenant id. + public string CreatedBy { get; } + /// Modified by user/tenant id. + public string ModifiedBy { get; } + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary Properties { get; } + /// Schema Foreign Key. + public string SchemaId { get; set; } + /// Id of the Catalog. + public string CatalogId { get; } + /// Unique resource ID. + public string Id { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collections.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collections.cs new file mode 100644 index 000000000000..cf441408b568 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Collections.cs @@ -0,0 +1,636 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The Collections sub-client. + public partial class Collections + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Collections for mocking. + protected Collections() + { + } + + /// Initializes a new instance of Collections. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal Collections(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Gets a specified Collection resource. + /// Id of the Catalog. + /// Unique resource ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetCollectionAsync(string catalogId, string collectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetCollectionAsync(catalogId, collectionId, context).ConfigureAwait(false); + return Response.FromValue(Collection.FromResponse(response), response); + } + + /// Gets a specified Collection resource. + /// Id of the Catalog. + /// Unique resource ID. + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetCollection(string catalogId, string collectionId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetCollection(catalogId, collectionId, context); + return Response.FromValue(Collection.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a specified Collection resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetCollectionAsync(string catalogId, string collectionId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + using var scope = ClientDiagnostics.CreateScope("Collections.GetCollection"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCollectionRequest(catalogId, collectionId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a specified Collection resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetCollection(string catalogId, string collectionId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + using var scope = ClientDiagnostics.CreateScope("Collections.GetCollection"); + scope.Start(); + try + { + using HttpMessage message = CreateGetCollectionRequest(catalogId, collectionId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Collection resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAsync(string catalogId, string collectionId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Collections.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(catalogId, collectionId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Collection resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdate(string catalogId, string collectionId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Collections.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(catalogId, collectionId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Collection for given Collection id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteAsync(string catalogId, string collectionId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + using var scope = ClientDiagnostics.CreateScope("Collections.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(catalogId, collectionId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Collection for given Collection id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Delete(string catalogId, string collectionId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + using var scope = ClientDiagnostics.CreateScope("Collections.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(catalogId, collectionId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Returns a paginated list of Collection resources. + /// Id of the Catalog. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual AsyncPageable GetCollectionsAsync(string catalogId, IEnumerable names = null, IEnumerable propertyFilters = null, IEnumerable statuses = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCollectionsRequest(catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCollectionsNextPageRequest(nextLink, catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Collection.DeserializeCollection(e), ClientDiagnostics, _pipeline, "Collections.GetCollections", "value", "nextLink", context); + } + + /// Returns a paginated list of Collection resources. + /// Id of the Catalog. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Pageable GetCollections(string catalogId, IEnumerable names = null, IEnumerable propertyFilters = null, IEnumerable statuses = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCollectionsRequest(catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCollectionsNextPageRequest(nextLink, catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Collection.DeserializeCollection(e), ClientDiagnostics, _pipeline, "Collections.GetCollections", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Returns a paginated list of Collection resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetCollectionsAsync(string catalogId, IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCollectionsRequest(catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCollectionsNextPageRequest(nextLink, catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Collections.GetCollections", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Returns a paginated list of Collection resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetCollections(string catalogId, IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetCollectionsRequest(catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetCollectionsNextPageRequest(nextLink, catalogId, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Collections.GetCollections", "value", "nextLink", context); + } + + internal HttpMessage CreateGetCollectionsRequest(string catalogId, IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (names != null && !(names is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + foreach (var param in names) + { + uri.AppendQuery("names", param, true); + } + } + if (propertyFilters != null && !(propertyFilters is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + foreach (var param in propertyFilters) + { + uri.AppendQuery("propertyFilters", param, true); + } + } + if (statuses != null && !(statuses is ChangeTrackingList changeTrackingList1 && changeTrackingList1.IsUndefined)) + { + foreach (var param in statuses) + { + uri.AppendQuery("statuses", param, true); + } + } + if (ids != null && !(ids is ChangeTrackingList changeTrackingList2 && changeTrackingList2.IsUndefined)) + { + foreach (var param in ids) + { + uri.AppendQuery("ids", param, true); + } + } + if (minCreatedDateTime != null) + { + uri.AppendQuery("minCreatedDateTime", minCreatedDateTime.Value, "O", true); + } + if (maxCreatedDateTime != null) + { + uri.AppendQuery("maxCreatedDateTime", maxCreatedDateTime.Value, "O", true); + } + if (minLastModifiedDateTime != null) + { + uri.AppendQuery("minLastModifiedDateTime", minLastModifiedDateTime.Value, "O", true); + } + if (maxLastModifiedDateTime != null) + { + uri.AppendQuery("maxLastModifiedDateTime", maxLastModifiedDateTime.Value, "O", true); + } + if (maxPageSize != null) + { + uri.AppendQuery("maxPageSize", maxPageSize.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetCollectionRequest(string catalogId, string collectionId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string catalogId, string collectionId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(string catalogId, string collectionId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetCollectionsNextPageRequest(string nextLink, string catalogId, IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateJobRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateJobRequest.Serialization.cs new file mode 100644 index 000000000000..d20d7e0a2f68 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateJobRequest.Serialization.cs @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class CreateJobRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateJobRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + writer.WritePropertyName("requestPath"u8); + writer.WriteStringValue(RequestPath); + writer.WritePropertyName("partnerRequestBody"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestBody) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + writer.WritePropertyName("partnerRequestHeaders"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestHeaders) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + writer.WritePropertyName("inputData"u8); + writer.WriteStartObject(); + foreach (var item in InputData) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateJobRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateJobRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateJobRequest(document.RootElement, options); + } + + internal static CreateJobRequest DeserializeCreateJobRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + string requestPath = default; + IReadOnlyDictionary partnerRequestBody = default; + IReadOnlyDictionary partnerRequestHeaders = default; + IReadOnlyDictionary inputData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("solutionId"u8)) + { + solutionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestPath"u8)) + { + requestPath = property.Value.GetString(); + continue; + } + if (property.NameEquals("partnerRequestBody"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestBody = dictionary; + continue; + } + if (property.NameEquals("partnerRequestHeaders"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestHeaders = dictionary; + continue; + } + if (property.NameEquals("inputData"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + inputData = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateJobRequest( + solutionId, + requestPath, + partnerRequestBody, + partnerRequestHeaders, + inputData, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateJobRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateJobRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateJobRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateJobRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateJobRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateJobRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateJobRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateJobRequest.cs new file mode 100644 index 000000000000..bf4546cd1821 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateJobRequest.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The CreateJobRequest. + internal partial class CreateJobRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// , , , or is null. + internal CreateJobRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + Argument.AssertNotNull(inputData, nameof(inputData)); + + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + InputData = inputData; + } + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// Keeps track of any properties unknown to the library. + internal CreateJobRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData, IDictionary serializedAdditionalRawData) + { + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + InputData = inputData; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateJobRequest() + { + } + + /// SolutionId. + public string SolutionId { get; } + /// RequestPath. + public string RequestPath { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestBody { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestHeaders { get; } + /// + /// Input Data. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary InputData { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateRequest.Serialization.cs new file mode 100644 index 000000000000..06259a967ee8 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateRequest.Serialization.cs @@ -0,0 +1,332 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class CreateRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Links)) + { + writer.WritePropertyName("links"u8); + writer.WriteStartArray(); + foreach (var item in Links) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + writer.WritePropertyName("data"u8); + writer.WriteStartObject(); + foreach (var item in Data) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (Optional.IsDefined(OwnerItemId)) + { + writer.WritePropertyName("ownerItemId"u8); + writer.WriteStringValue(OwnerItemId); + } + if (Optional.IsCollectionDefined(Assets)) + { + writer.WritePropertyName("assets"u8); + writer.WriteStartArray(); + foreach (var item in Assets) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + CreateRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(CreateRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeCreateRequest(document.RootElement, options); + } + + internal static CreateRequest DeserializeCreateRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList links = default; + string status = default; + string source = default; + string name = default; + string description = default; + IReadOnlyDictionary properties = default; + IReadOnlyDictionary data = default; + string ownerItemId = default; + IReadOnlyList assets = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("links"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Link.DeserializeLink(item, options)); + } + links = array; + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + properties = dictionary; + continue; + } + if (property.NameEquals("data"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + data = dictionary; + continue; + } + if (property.NameEquals("ownerItemId"u8)) + { + ownerItemId = property.Value.GetString(); + continue; + } + if (property.NameEquals("assets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Asset.DeserializeAsset(item, options)); + } + assets = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new CreateRequest( + links ?? new ChangeTrackingList(), + status, + source, + name, + description, + properties ?? new ChangeTrackingDictionary(), + data, + ownerItemId, + assets ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(CreateRequest)} does not support writing '{options.Format}' format."); + } + } + + CreateRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(CreateRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static CreateRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeCreateRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateRequest.cs new file mode 100644 index 000000000000..e4bb0045e587 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/CreateRequest.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The CreateRequest. + internal partial class CreateRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Schema for records under the dataset. + /// is null. + internal CreateRequest(IReadOnlyDictionary data) + { + Argument.AssertNotNull(data, nameof(data)); + + Links = new ChangeTrackingList(); + Properties = new ChangeTrackingDictionary(); + Data = data; + Assets = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// Status of the resource. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Schema for records under the dataset. + /// OwnerItemId. + /// Assets. + /// Keeps track of any properties unknown to the library. + internal CreateRequest(IReadOnlyList links, string status, string source, string name, string description, IReadOnlyDictionary properties, IReadOnlyDictionary data, string ownerItemId, IReadOnlyList assets, IDictionary serializedAdditionalRawData) + { + Links = links; + Status = status; + Source = source; + Name = name; + Description = description; + Properties = properties; + Data = data; + OwnerItemId = ownerItemId; + Assets = assets; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal CreateRequest() + { + } + + /// Links for referencing other objects. + public IReadOnlyList Links { get; } + /// Status of the resource. + public string Status { get; } + /// Source of the resource. + public string Source { get; } + /// Name to identify resource. + public string Name { get; } + /// Textual description of the resource. + public string Description { get; } + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary Properties { get; } + /// + /// Schema for records under the dataset. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary Data { get; } + /// OwnerItemId. + public string OwnerItemId { get; } + /// Assets. + public IReadOnlyList Assets { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DataFormat.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DataFormat.cs new file mode 100644 index 000000000000..89d6c65abaca --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DataFormat.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AgriculturePlatform +{ + /// Type of dataset. + public readonly partial struct DataFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DataFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string ImageValue = "Image"; + private const string ShapefileValue = "Shapefile"; + private const string BinaryValue = "Binary"; + + /// Image. + public static DataFormat Image { get; } = new DataFormat(ImageValue); + /// Shapefile. + public static DataFormat Shapefile { get; } = new DataFormat(ShapefileValue); + /// Binary. + public static DataFormat Binary { get; } = new DataFormat(BinaryValue); + /// Determines if two values are the same. + public static bool operator ==(DataFormat left, DataFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DataFormat left, DataFormat right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DataFormat(string value) => new DataFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DataFormat other && Equals(other); + /// + public bool Equals(DataFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DeleteRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DeleteRequest.Serialization.cs new file mode 100644 index 000000000000..6d6577e5f005 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DeleteRequest.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class DeleteRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeleteRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("filePath"u8); + writer.WriteStringValue(FilePath); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DeleteRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DeleteRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDeleteRequest(document.RootElement, options); + } + + internal static DeleteRequest DeserializeDeleteRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string filePath = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filePath"u8)) + { + filePath = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DeleteRequest(filePath, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DeleteRequest)} does not support writing '{options.Format}' format."); + } + } + + DeleteRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeleteRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DeleteRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DeleteRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDeleteRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DeleteRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DeleteRequest.cs new file mode 100644 index 000000000000..42be16a9607d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DeleteRequest.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The DeleteRequest. + internal partial class DeleteRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// FilePath. + /// is null. + internal DeleteRequest(string filePath) + { + Argument.AssertNotNull(filePath, nameof(filePath)); + + FilePath = filePath; + } + + /// Initializes a new instance of . + /// FilePath. + /// Keeps track of any properties unknown to the library. + internal DeleteRequest(string filePath, IDictionary serializedAdditionalRawData) + { + FilePath = filePath; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DeleteRequest() + { + } + + /// FilePath. + public string FilePath { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DestinationType.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DestinationType.cs new file mode 100644 index 000000000000..95120d81e19d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DestinationType.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AgriculturePlatform +{ + /// DestinationType. + public readonly partial struct DestinationType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public DestinationType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string CatalogValue = "Catalog"; + private const string CollectionValue = "Collection"; + private const string ItemValue = "Item"; + private const string AssetValue = "Asset"; + + /// Catalog. + public static DestinationType Catalog { get; } = new DestinationType(CatalogValue); + /// Collection. + public static DestinationType Collection { get; } = new DestinationType(CollectionValue); + /// Item. + public static DestinationType Item { get; } = new DestinationType(ItemValue); + /// Asset. + public static DestinationType Asset { get; } = new DestinationType(AssetValue); + /// Determines if two values are the same. + public static bool operator ==(DestinationType left, DestinationType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(DestinationType left, DestinationType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator DestinationType(string value) => new DestinationType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is DestinationType other && Equals(other); + /// + public bool Equals(DestinationType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Catalogs.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Catalogs.xml new file mode 100644 index 000000000000..030ced450357 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Catalogs.xml @@ -0,0 +1,207 @@ + + + + + +This sample shows how to call GetCatalogAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetCatalogAsync("CATALOG123"); +]]> + + + +This sample shows how to call GetCatalog. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetCatalog("CATALOG123"); +]]> + + + +This sample shows how to call GetCatalogAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetCatalogAsync("CATALOG123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call GetCatalog and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetCatalog("CATALOG123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = await client.CreateOrUpdateAsync("CATALOG123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdate and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = client.CreateOrUpdate("CATALOG123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call DeleteAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.DeleteAsync("CATALOG123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Delete("CATALOG123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetCatalogsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +await foreach (Catalog item in client.GetCatalogsAsync()) +{ +} +]]> + + + +This sample shows how to call GetCatalogs. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +foreach (Catalog item in client.GetCatalogs()) +{ +} +]]> + + + +This sample shows how to call GetCatalogsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +await foreach (BinaryData item in client.GetCatalogsAsync(null, null, null, null, null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); +} +]]> + + + +This sample shows how to call GetCatalogs and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + +foreach (BinaryData item in client.GetCatalogs(null, null, null, null, null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Collections.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Collections.xml new file mode 100644 index 000000000000..f706dc74f3c1 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Collections.xml @@ -0,0 +1,215 @@ + + + + + +This sample shows how to call GetCollectionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetCollectionAsync("CATALOG123", "COLLECTION123"); +]]> + + + +This sample shows how to call GetCollection. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetCollection("CATALOG123", "COLLECTION123"); +]]> + + + +This sample shows how to call GetCollectionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetCollectionAsync("CATALOG123", "COLLECTION123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaId").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call GetCollection and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetCollection("CATALOG123", "COLLECTION123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaId").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + schemaId = "SCHEMA123", + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = await client.CreateOrUpdateAsync("CATALOG123", "COLLECTION123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaId").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdate and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + schemaId = "SCHEMA123", + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = client.CreateOrUpdate("CATALOG123", "COLLECTION123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaId").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call DeleteAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.DeleteAsync("CATALOG123", "COLLECTION123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Delete("CATALOG123", "COLLECTION123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetCollectionsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +await foreach (Collection item in client.GetCollectionsAsync("CATALOG123")) +{ +} +]]> + + + +This sample shows how to call GetCollections. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +foreach (Collection item in client.GetCollections("CATALOG123")) +{ +} +]]> + + + +This sample shows how to call GetCollectionsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +await foreach (BinaryData item in client.GetCollectionsAsync("CATALOG123", null, null, null, null, null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); +} +]]> + + + +This sample shows how to call GetCollections and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + +foreach (BinaryData item in client.GetCollections("CATALOG123", null, null, null, null, null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/File.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/File.xml new file mode 100644 index 000000000000..959e35de29f2 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/File.xml @@ -0,0 +1,169 @@ + + + + + +This sample shows how to call DeleteAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.DeleteAsync("string"); +]]> + + + +This sample shows how to call Delete. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Delete("string"); +]]> + + + +This sample shows how to call DeleteAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + filePath = "string", +}); +Response response = await client.DeleteAsync(content); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + filePath = "string", +}); +Response response = client.Delete(content); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call DownloadAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.DownloadAsync(AcceptHeaderEnum.Json, "string"); +]]> + + + +This sample shows how to call Download. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Download(AcceptHeaderEnum.Json, "string"); +]]> + + + +This sample shows how to call DownloadAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + filePath = "string", +}); +Response response = await client.DownloadAsync("application/json", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call Download and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + filePath = "string", +}); +Response response = client.Download("application/json", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call UploadAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.UploadAsync(); +]]> + + + +This sample shows how to call Upload. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Upload(); +]]> + + + +This sample shows how to call UploadAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.UploadAsync(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("filePath").ToString()); +]]> + + + +This sample shows how to call Upload and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Upload(null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("filePath").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Items.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Items.xml new file mode 100644 index 000000000000..c740e96a591c --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Items.xml @@ -0,0 +1,425 @@ + + + + + +This sample shows how to call CreateAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.CreateAsync("CATALOG123", "COLLECTION123", new Dictionary +{ + ["additionalProp1"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp2"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp3"] = BinaryData.FromObjectAsJson("string") +}); +]]> + + + +This sample shows how to call Create. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Create("CATALOG123", "COLLECTION123", new Dictionary +{ + ["additionalProp1"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp2"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp3"] = BinaryData.FromObjectAsJson("string") +}); +]]> + + + +This sample shows how to call CreateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + data = new + { + additionalProp1 = "string", + additionalProp2 = "string", + additionalProp3 = "string", + }, + assets = new object[] + { + new + { + type = "Image", + name = "string", + href = "string", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = await client.CreateAsync("CATALOG123", "COLLECTION123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); +]]> + + + +This sample shows how to call Create and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + data = new + { + additionalProp1 = "string", + additionalProp2 = "string", + additionalProp3 = "string", + }, + assets = new object[] + { + new + { + type = "Image", + name = "string", + href = "string", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = client.Create("CATALOG123", "COLLECTION123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); +]]> + + + +This sample shows how to call GetItemAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetItemAsync("CATALOG123", "COLLECTION123", "ITEM123"); +]]> + + + +This sample shows how to call GetItem. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetItem("CATALOG123", "COLLECTION123", "ITEM123"); +]]> + + + +This sample shows how to call GetItemAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetItemAsync("CATALOG123", "COLLECTION123", "ITEM123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call GetItem and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetItem("CATALOG123", "COLLECTION123", "ITEM123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + data = new + { + Company = "string", + name = "string", + }, + ownerItemId = "lavi-item", + assets = new object[] + { + new + { + type = "Image", + name = "string", + href = "string", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = await client.CreateOrUpdateAsync("CATALOG123", "COLLECTION123", "ITEM123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdate and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + links = new object[] + { + new + { + rel = "DerivedFrom", + href = "string", + type = "Catalog", + } + }, + data = new + { + Company = "string", + name = "string", + }, + ownerItemId = "lavi-item", + assets = new object[] + { + new + { + type = "Image", + name = "string", + href = "string", + } + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, +}); +Response response = client.CreateOrUpdate("CATALOG123", "COLLECTION123", "ITEM123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call DeleteAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.DeleteAsync("CATALOG123", "COLLECTION123", "ITEM123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Delete("CATALOG123", "COLLECTION123", "ITEM123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetAllUnderCollectionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetAllUnderCollectionAsync("CATALOG123", "COLLECTION123"); +]]> + + + +This sample shows how to call GetAllUnderCollection. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetAllUnderCollection("CATALOG123", "COLLECTION123"); +]]> + + + +This sample shows how to call GetAllUnderCollectionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new object()); +Response response = await client.GetAllUnderCollectionAsync("CATALOG123", "COLLECTION123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); +]]> + + + +This sample shows how to call GetAllUnderCollection and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new object()); +Response response = client.GetAllUnderCollection("CATALOG123", "COLLECTION123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); +]]> + + + +This sample shows how to call SearchAcrossCollectionAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.SearchAcrossCollectionAsync("CATALOG123"); +]]> + + + +This sample shows how to call SearchAcrossCollection. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.SearchAcrossCollection("CATALOG123"); +]]> + + + +This sample shows how to call SearchAcrossCollectionAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new object()); +Response response = await client.SearchAcrossCollectionAsync("CATALOG123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); +]]> + + + +This sample shows how to call SearchAcrossCollection and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new object()); +Response response = client.SearchAcrossCollection("CATALOG123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Satellite.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Satellite.xml new file mode 100644 index 000000000000..a2e5b1622411 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Satellite.xml @@ -0,0 +1,333 @@ + + + + + +This sample shows how to call FetchItemsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); +SatelliteData data = new SatelliteData +{ + ImageNames = { "NDVI", "B04", "B08", "dataMask", "CLM" }, + ImageFormats = { "TIF" }, + ImageResolutions = { 10 }, +}; +Response response = await client.FetchItemsAsync(credentials, "SentinelHub", "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", data, "sentinel-2-l2a"); +]]> + + + +This sample shows how to call FetchItems. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); +SatelliteData data = new SatelliteData +{ + ImageNames = { "NDVI", "B04", "B08", "dataMask", "CLM" }, + ImageFormats = { "TIF" }, + ImageResolutions = { 10 }, +}; +Response response = client.FetchItems(credentials, "SentinelHub", "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", data, "sentinel-2-l2a"); +]]> + + + +This sample shows how to call FetchItemsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + startDateTime = "2024-06-05T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-14T12:42:29.217Z", + provider = "SentinelHub", + itemUri = "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", + data = new + { + imageNames = new object[] + { + "NDVI", + "B04", + "B08", + "dataMask", + "CLM" + }, + imageFormats = new object[] + { + "TIF" + }, + imageResolutions = new object[] + { + 10 + }, + }, + providerCollectionId = "sentinel-2-l2a", +}); +Response response = await client.FetchItemsAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call FetchItems and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + startDateTime = "2024-06-05T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-14T12:42:29.217Z", + provider = "SentinelHub", + itemUri = "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", + data = new + { + imageNames = new object[] + { + "NDVI", + "B04", + "B08", + "dataMask", + "CLM" + }, + imageFormats = new object[] + { + "TIF" + }, + imageResolutions = new object[] + { + 10 + }, + }, + providerCollectionId = "sentinel-2-l2a", +}); +Response response = client.FetchItems(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call SearchItemsAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); +Response response = await client.SearchItemsAsync(credentials, "SentinelHub", "sentinel-2-l2a"); +]]> + + + +This sample shows how to call SearchItems. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); +Response response = client.SearchItems(credentials, "SentinelHub", "sentinel-2-l2a"); +]]> + + + +This sample shows how to call SearchItemsAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + startDateTime = "2024-06-15T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-22T12:42:29.217Z", + intersects = new + { + type = "Polygon", + coordinates = new object[] + { + new object[] + { + new object[] + { + 73.70457172393799, + 20.545385304358106 + }, + new object[] + { + 73.70457172393799, + 20.545385304358106 + }, + new object[] + { + 73.70448589324951, + 20.542411534243367 + }, + new object[] + { + 73.70877742767334, + 20.541688176010233 + }, + new object[] + { + 73.71023654937744, + 20.545083911372505 + }, + new object[] + { + 73.70663166046143, + 20.546992723579137 + }, + new object[] + { + 73.70457172393799, + 20.545385304358106 + } + } + }, + }, + providerCollectionId = "sentinel-2-l2a", + provider = "SentinelHub", +}); +Response response = await client.SearchItemsAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("").ToString()); +]]> + + + +This sample shows how to call SearchItems and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + startDateTime = "2024-06-15T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-22T12:42:29.217Z", + intersects = new + { + type = "Polygon", + coordinates = new object[] + { + new object[] + { + new object[] + { + 73.70457172393799, + 20.545385304358106 + }, + new object[] + { + 73.70457172393799, + 20.545385304358106 + }, + new object[] + { + 73.70448589324951, + 20.542411534243367 + }, + new object[] + { + 73.70877742767334, + 20.541688176010233 + }, + new object[] + { + 73.71023654937744, + 20.545083911372505 + }, + new object[] + { + 73.70663166046143, + 20.546992723579137 + }, + new object[] + { + 73.70457172393799, + 20.545385304358106 + } + } + }, + }, + providerCollectionId = "sentinel-2-l2a", + provider = "SentinelHub", +}); +Response response = client.SearchItems(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].ToString()); +Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Schemas.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Schemas.xml new file mode 100644 index 000000000000..e51fdbe15691 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Schemas.xml @@ -0,0 +1,217 @@ + + + + + +This sample shows how to call GetSchemaAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetSchemaAsync("SCHEMA123"); +]]> + + + +This sample shows how to call GetSchema. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetSchema("SCHEMA123"); +]]> + + + +This sample shows how to call GetSchemaAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetSchemaAsync("SCHEMA123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call GetSchema and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetSchema("SCHEMA123", null); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdateAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + schemaModel = new + { + type = "object", + properties = new Dictionary + { + ["$id"] = "3308", + ["name"] = new Dictionary + { + ["$id"] = "3309", + ["type"] = "string", + ["minLength"] = 2, + ["maxLength"] = 100 + }, + ["geometry"] = new Dictionary + { + ["$id"] = "3310", + ["type"] = "object" + } + }, + }, +}); +Response response = await client.CreateOrUpdateAsync("SCHEMA123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call CreateOrUpdate and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + schemaModel = new + { + type = "object", + properties = new Dictionary + { + ["$id"] = "3308", + ["name"] = new Dictionary + { + ["$id"] = "3309", + ["type"] = "string", + ["minLength"] = 2, + ["maxLength"] = 100 + }, + ["geometry"] = new Dictionary + { + ["$id"] = "3310", + ["type"] = "object" + } + }, + }, +}); +Response response = client.CreateOrUpdate("SCHEMA123", content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); +Console.WriteLine(result.GetProperty("id").ToString()); +]]> + + + +This sample shows how to call DeleteAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.DeleteAsync("SCHEMA123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call Delete. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +Response response = client.Delete("SCHEMA123"); + +Console.WriteLine(response.Status); +]]> + + + +This sample shows how to call GetSchemasAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +await foreach (Schema item in client.GetSchemasAsync()) +{ +} +]]> + + + +This sample shows how to call GetSchemas. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +foreach (Schema item in client.GetSchemas()) +{ +} +]]> + + + +This sample shows how to call GetSchemasAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +await foreach (BinaryData item in client.GetSchemasAsync(null, null, null, null, null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); +} +]]> + + + +This sample shows how to call GetSchemas and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + +foreach (BinaryData item in client.GetSchemas(null, null, null, null, null, null, null, null, null, null, null)) +{ + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); +} +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Solutions.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Solutions.xml new file mode 100644 index 000000000000..116df9cf6d63 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Solutions.xml @@ -0,0 +1,265 @@ + + + + + +This sample shows how to call CancelJobAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.CancelJobAsync("string", "string", new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call CancelJob. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.CancelJob("string", "string", new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call CancelJobAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = await client.CancelJobAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call CancelJob and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = client.CancelJob(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call CreateJobAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.CreateJobAsync("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call CreateJob. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.CreateJob("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call CreateJobAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = await client.CreateJobAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call CreateJob and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = client.CreateJob(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call GetDataAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetDataAsync("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call GetData. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetData("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call GetDataAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = await client.GetDataAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call GetData and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = client.GetData(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call GetJobAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetJobAsync("string", "string", new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call GetJob. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetJob("string", "string", new Dictionary(), new Dictionary()); +]]> + + + +This sample shows how to call GetJobAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = await client.GetJobAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + +This sample shows how to call GetJob and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), +}); +Response response = client.GetJob(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Weather.xml b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Weather.xml new file mode 100644 index 000000000000..ea2db28233ca --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Docs/Weather.xml @@ -0,0 +1,109 @@ + + + + + +This sample shows how to call GetWeatherOperationAsync. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + +Response response = await client.GetWeatherOperationAsync("string", "string", "string"); +]]> + + + +This sample shows how to call GetWeatherOperation. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + +Response response = client.GetWeatherOperation("string", "string", "string"); +]]> + + + +This sample shows how to call GetWeatherOperationAsync and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + credentials = new + { + apiKey = new + { + keyVaultUri = "string", + keyName = "string", + keyVersion = "string", + }, + }, + locations = new object[] + { + new + { + type = "string", + value = "string", + } + }, + providerName = "string", + providerApiName = "string", + language = "en-US", + units = "string", +}); +Response response = await client.GetWeatherOperationAsync(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerName").ToString()); +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerApiName").ToString()); +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("units").ToString()); +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("weatherDataType").ToString()); +]]> + + + +This sample shows how to call GetWeatherOperation and parse the result. +"); +AzureKeyCredential credential = new AzureKeyCredential(""); +Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + +using RequestContent content = RequestContent.Create(new +{ + credentials = new + { + apiKey = new + { + keyVaultUri = "string", + keyName = "string", + keyVersion = "string", + }, + }, + locations = new object[] + { + new + { + type = "string", + value = "string", + } + }, + providerName = "string", + providerApiName = "string", + language = "en-US", + units = "string", +}); +Response response = client.GetWeatherOperation(content); + +JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerName").ToString()); +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerApiName").ToString()); +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("units").ToString()); +Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("weatherDataType").ToString()); +]]> + + + \ No newline at end of file diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DownloadRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DownloadRequest.Serialization.cs new file mode 100644 index 000000000000..c4f422201db3 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DownloadRequest.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class DownloadRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DownloadRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("filePath"u8); + writer.WriteStringValue(FilePath); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + DownloadRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(DownloadRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeDownloadRequest(document.RootElement, options); + } + + internal static DownloadRequest DeserializeDownloadRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string filePath = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filePath"u8)) + { + filePath = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new DownloadRequest(filePath, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(DownloadRequest)} does not support writing '{options.Format}' format."); + } + } + + DownloadRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDownloadRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(DownloadRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static DownloadRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeDownloadRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DownloadRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DownloadRequest.cs new file mode 100644 index 000000000000..af63406bb831 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/DownloadRequest.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The DownloadRequest. + internal partial class DownloadRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// FilePath. + /// is null. + internal DownloadRequest(string filePath) + { + Argument.AssertNotNull(filePath, nameof(filePath)); + + FilePath = filePath; + } + + /// Initializes a new instance of . + /// FilePath. + /// Keeps track of any properties unknown to the library. + internal DownloadRequest(string filePath, IDictionary serializedAdditionalRawData) + { + FilePath = filePath; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal DownloadRequest() + { + } + + /// FilePath. + public string FilePath { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ErrorForLocation.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ErrorForLocation.Serialization.cs new file mode 100644 index 000000000000..98b4b918be63 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ErrorForLocation.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class ErrorForLocation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ErrorForLocation)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteObjectValue(Location, options); + } + if (Optional.IsDefined(Code)) + { + writer.WritePropertyName("code"u8); + writer.WriteNumberValue(Code.Value); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Retryable)) + { + writer.WritePropertyName("retryable"u8); + writer.WriteBooleanValue(Retryable.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ErrorForLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ErrorForLocation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeErrorForLocation(document.RootElement, options); + } + + internal static ErrorForLocation DeserializeErrorForLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WeatherLocation location = default; + int? code = default; + string description = default; + bool? retryable = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = WeatherLocation.DeserializeWeatherLocation(property.Value, options); + continue; + } + if (property.NameEquals("code"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + code = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("retryable"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + retryable = property.Value.GetBoolean(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ErrorForLocation(location, code, description, retryable, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ErrorForLocation)} does not support writing '{options.Format}' format."); + } + } + + ErrorForLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeErrorForLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ErrorForLocation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ErrorForLocation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeErrorForLocation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ErrorForLocation.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ErrorForLocation.cs new file mode 100644 index 000000000000..c139d66dc3f0 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ErrorForLocation.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Model for error information for a failed location. + public partial class ErrorForLocation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal ErrorForLocation() + { + } + + /// Initializes a new instance of . + /// Schema of Location data. + /// Status code returned by data provider. + /// Description of the error. + /// + /// Flag suggesting if retry attempt with same request body should be made to fetch + /// required data. + /// + /// Keeps track of any properties unknown to the library. + internal ErrorForLocation(WeatherLocation location, int? code, string description, bool? retryable, IDictionary serializedAdditionalRawData) + { + Location = location; + Code = code; + Description = description; + Retryable = retryable; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Schema of Location data. + public WeatherLocation Location { get; } + /// Status code returned by data provider. + public int? Code { get; } + /// Description of the error. + public string Description { get; } + /// + /// Flag suggesting if retry attempt with same request body should be made to fetch + /// required data. + /// + public bool? Retryable { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FetchItemsRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FetchItemsRequest.Serialization.cs new file mode 100644 index 000000000000..2434f313a5f6 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FetchItemsRequest.Serialization.cs @@ -0,0 +1,224 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class FetchItemsRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FetchItemsRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(StartDateTime)) + { + writer.WritePropertyName("startDateTime"u8); + writer.WriteStringValue(StartDateTime.Value, "O"); + } + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + if (Optional.IsDefined(EndDateTime)) + { + writer.WritePropertyName("endDateTime"u8); + writer.WriteStringValue(EndDateTime.Value, "O"); + } + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + writer.WritePropertyName("itemUri"u8); + writer.WriteStringValue(ItemUri); + writer.WritePropertyName("data"u8); + writer.WriteObjectValue(Data, options); + writer.WritePropertyName("providerCollectionId"u8); + writer.WriteStringValue(ProviderCollectionId); + if (Optional.IsDefined(FeatureId)) + { + writer.WritePropertyName("featureId"u8); + writer.WriteStringValue(FeatureId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FetchItemsRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FetchItemsRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFetchItemsRequest(document.RootElement, options); + } + + internal static FetchItemsRequest DeserializeFetchItemsRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset? startDateTime = default; + OauthClientCredentials credentials = default; + DateTimeOffset? endDateTime = default; + string provider = default; + string itemUri = default; + SatelliteData data = default; + string providerCollectionId = default; + string featureId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("startDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("credentials"u8)) + { + credentials = OauthClientCredentials.DeserializeOauthClientCredentials(property.Value, options); + continue; + } + if (property.NameEquals("endDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("itemUri"u8)) + { + itemUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("data"u8)) + { + data = SatelliteData.DeserializeSatelliteData(property.Value, options); + continue; + } + if (property.NameEquals("providerCollectionId"u8)) + { + providerCollectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("featureId"u8)) + { + featureId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FetchItemsRequest( + startDateTime, + credentials, + endDateTime, + provider, + itemUri, + data, + providerCollectionId, + featureId, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FetchItemsRequest)} does not support writing '{options.Format}' format."); + } + } + + FetchItemsRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFetchItemsRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FetchItemsRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FetchItemsRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFetchItemsRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FetchItemsRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FetchItemsRequest.cs new file mode 100644 index 000000000000..8444ec6ddf9c --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FetchItemsRequest.cs @@ -0,0 +1,115 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The FetchItemsRequest. + internal partial class FetchItemsRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// OAuthClientCredentials for clientId clientSecret auth. + /// Provider of satellite data. Available Value: SentinelHub. + /// ItemUri. + /// Data Model for SatelliteIngestionJobRequest. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// , , , or is null. + internal FetchItemsRequest(OauthClientCredentials credentials, string provider, string itemUri, SatelliteData data, string providerCollectionId) + { + Argument.AssertNotNull(credentials, nameof(credentials)); + Argument.AssertNotNull(provider, nameof(provider)); + Argument.AssertNotNull(itemUri, nameof(itemUri)); + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(providerCollectionId, nameof(providerCollectionId)); + + Credentials = credentials; + Provider = provider; + ItemUri = itemUri; + Data = data; + ProviderCollectionId = providerCollectionId; + } + + /// Initializes a new instance of . + /// Start Date. + /// OAuthClientCredentials for clientId clientSecret auth. + /// End Date. + /// Provider of satellite data. Available Value: SentinelHub. + /// ItemUri. + /// Data Model for SatelliteIngestionJobRequest. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Feature Id. + /// Keeps track of any properties unknown to the library. + internal FetchItemsRequest(DateTimeOffset? startDateTime, OauthClientCredentials credentials, DateTimeOffset? endDateTime, string provider, string itemUri, SatelliteData data, string providerCollectionId, string featureId, IDictionary serializedAdditionalRawData) + { + StartDateTime = startDateTime; + Credentials = credentials; + EndDateTime = endDateTime; + Provider = provider; + ItemUri = itemUri; + Data = data; + ProviderCollectionId = providerCollectionId; + FeatureId = featureId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FetchItemsRequest() + { + } + + /// Start Date. + public DateTimeOffset? StartDateTime { get; } + /// OAuthClientCredentials for clientId clientSecret auth. + public OauthClientCredentials Credentials { get; } + /// End Date. + public DateTimeOffset? EndDateTime { get; } + /// Provider of satellite data. Available Value: SentinelHub. + public string Provider { get; } + /// ItemUri. + public string ItemUri { get; } + /// Data Model for SatelliteIngestionJobRequest. + public SatelliteData Data { get; } + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + public string ProviderCollectionId { get; } + /// Feature Id. + public string FeatureId { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/File.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/File.cs new file mode 100644 index 000000000000..7c343b47e033 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/File.cs @@ -0,0 +1,427 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The File sub-client. + public partial class File + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of File for mocking. + protected File() + { + } + + /// Initializes a new instance of File. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal File(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Deletes file. + /// FilePath. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task DeleteAsync(string filePath, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(filePath, nameof(filePath)); + + DeleteRequest deleteRequest = new DeleteRequest(filePath, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await DeleteAsync(deleteRequest.ToRequestContent(), context).ConfigureAwait(false); + return response; + } + + /// Deletes file. + /// FilePath. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Delete(string filePath, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(filePath, nameof(filePath)); + + DeleteRequest deleteRequest = new DeleteRequest(filePath, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Delete(deleteRequest.ToRequestContent(), context); + return response; + } + + /// + /// [Protocol Method] Deletes file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("File.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Deletes file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Delete(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("File.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Downloads and returns file Stream as response for the given input filePath. + /// Accept header. + /// FilePath. + /// The cancellation token to use. + /// is null. + /// + public virtual async Task> DownloadAsync(AcceptHeaderEnum accept, string filePath, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(filePath, nameof(filePath)); + + DownloadRequest downloadRequest = new DownloadRequest(filePath, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await DownloadAsync(accept.ToString(), downloadRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(response.Content, response); + } + + /// Downloads and returns file Stream as response for the given input filePath. + /// Accept header. + /// FilePath. + /// The cancellation token to use. + /// is null. + /// + public virtual Response Download(AcceptHeaderEnum accept, string filePath, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(filePath, nameof(filePath)); + + DownloadRequest downloadRequest = new DownloadRequest(filePath, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Download(accept.ToString(), downloadRequest.ToRequestContent(), context); + return Response.FromValue(response.Content, response); + } + + /// + /// [Protocol Method] Downloads and returns file Stream as response for the given input filePath. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Accept header. Allowed values: "application/json" | "application/octet-stream". + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DownloadAsync(string accept, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(accept, nameof(accept)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("File.Download"); + scope.Start(); + try + { + using HttpMessage message = CreateDownloadRequest(accept, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Downloads and returns file Stream as response for the given input filePath. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Accept header. Allowed values: "application/json" | "application/octet-stream". + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Download(string accept, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(accept, nameof(accept)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("File.Download"); + scope.Start(); + try + { + using HttpMessage message = CreateDownloadRequest(accept, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Uploads a file. + /// The cancellation token to use. + /// + public virtual async Task> UploadAsync(CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await UploadAsync(context).ConfigureAwait(false); + return Response.FromValue(FileModel.FromResponse(response), response); + } + + /// Uploads a file. + /// The cancellation token to use. + /// + public virtual Response Upload(CancellationToken cancellationToken = default) + { + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Upload(context); + return Response.FromValue(FileModel.FromResponse(response), response); + } + + /// + /// [Protocol Method] Uploads a file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task UploadAsync(RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("File.Upload"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadRequest(context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Uploads a file. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Upload(RequestContext context) + { + using var scope = ClientDiagnostics.CreateScope("File.Upload"); + scope.Start(); + try + { + using HttpMessage message = CreateUploadRequest(context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateDeleteRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/file:delete", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDownloadRequest(string accept, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/file:download", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", accept); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateUploadRequest(RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/file:upload", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FileModel.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FileModel.Serialization.cs new file mode 100644 index 000000000000..ce58727d648c --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FileModel.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class FileModel : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileModel)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("filePath"u8); + writer.WriteStringValue(FilePath); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + FileModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(FileModel)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeFileModel(document.RootElement, options); + } + + internal static FileModel DeserializeFileModel(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string filePath = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filePath"u8)) + { + filePath = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new FileModel(filePath, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(FileModel)} does not support writing '{options.Format}' format."); + } + } + + FileModel IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileModel(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(FileModel)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static FileModel FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeFileModel(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FileModel.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FileModel.cs new file mode 100644 index 000000000000..49daf33c0152 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/FileModel.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// File. + public partial class FileModel + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// FilePath. + /// is null. + internal FileModel(string filePath) + { + Argument.AssertNotNull(filePath, nameof(filePath)); + + FilePath = filePath; + } + + /// Initializes a new instance of . + /// FilePath. + /// Keeps track of any properties unknown to the library. + internal FileModel(string filePath, IDictionary serializedAdditionalRawData) + { + FilePath = filePath; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal FileModel() + { + } + + /// FilePath. + public string FilePath { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObject.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObject.Serialization.cs new file mode 100644 index 000000000000..f43f60960419 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObject.Serialization.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + [PersistableModelProxy(typeof(UnknownGeoJsonObject))] + public partial class GeoJsonObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.ToString()); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + GeoJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGeoJsonObject(document.RootElement, options); + } + + internal static GeoJsonObject DeserializeGeoJsonObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + if (element.TryGetProperty("type", out JsonElement discriminator)) + { + switch (discriminator.GetString()) + { + case "MultiPolygon": return MultiPolygon.DeserializeMultiPolygon(element, options); + case "Point": return Point.DeserializePoint(element, options); + case "Polygon": return Polygon.DeserializePolygon(element, options); + } + } + return UnknownGeoJsonObject.DeserializeUnknownGeoJsonObject(element, options); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support writing '{options.Format}' format."); + } + } + + GeoJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGeoJsonObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static GeoJsonObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGeoJsonObject(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObject.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObject.cs new file mode 100644 index 000000000000..dd2ad15a2f98 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObject.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public abstract partial class GeoJsonObject + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private protected IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + protected GeoJsonObject() + { + } + + /// Initializes a new instance of . + /// Type of GeoJSON object. + /// Keeps track of any properties unknown to the library. + internal GeoJsonObject(GeoJsonObjectType type, IDictionary serializedAdditionalRawData) + { + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of GeoJSON object. + internal GeoJsonObjectType Type { get; set; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObjectType.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObjectType.cs new file mode 100644 index 000000000000..7ea91302cb44 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GeoJsonObjectType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AgriculturePlatform +{ + /// GeoJSON object type. + internal readonly partial struct GeoJsonObjectType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public GeoJsonObjectType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string PointValue = "Point"; + private const string PolygonValue = "Polygon"; + private const string MultiPolygonValue = "MultiPolygon"; + + /// Point. + public static GeoJsonObjectType Point { get; } = new GeoJsonObjectType(PointValue); + /// Polygon. + public static GeoJsonObjectType Polygon { get; } = new GeoJsonObjectType(PolygonValue); + /// MultiPolygon. + public static GeoJsonObjectType MultiPolygon { get; } = new GeoJsonObjectType(MultiPolygonValue); + /// Determines if two values are the same. + public static bool operator ==(GeoJsonObjectType left, GeoJsonObjectType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(GeoJsonObjectType left, GeoJsonObjectType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator GeoJsonObjectType(string value) => new GeoJsonObjectType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is GeoJsonObjectType other && Equals(other); + /// + public bool Equals(GeoJsonObjectType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetAllUnderCollectionRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetAllUnderCollectionRequest.Serialization.cs new file mode 100644 index 000000000000..6fdcf2fd2486 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetAllUnderCollectionRequest.Serialization.cs @@ -0,0 +1,321 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class GetAllUnderCollectionRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetAllUnderCollectionRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(OwnerItemIds)) + { + writer.WritePropertyName("ownerItemIds"u8); + writer.WriteStartArray(); + foreach (var item in OwnerItemIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DataFilters)) + { + writer.WritePropertyName("dataFilters"u8); + writer.WriteStartArray(); + foreach (var item in DataFilters) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(IntersectsWithGeometry)) + { + writer.WritePropertyName("intersectsWithGeometry"u8); + writer.WriteObjectValue(IntersectsWithGeometry, options); + } + if (Optional.IsCollectionDefined(Ids)) + { + writer.WritePropertyName("ids"u8); + writer.WriteStartArray(); + foreach (var item in Ids) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(MinCreatedDateTime)) + { + writer.WritePropertyName("minCreatedDateTime"u8); + writer.WriteStringValue(MinCreatedDateTime.Value, "O"); + } + if (Optional.IsDefined(MaxCreatedDateTime)) + { + writer.WritePropertyName("maxCreatedDateTime"u8); + writer.WriteStringValue(MaxCreatedDateTime.Value, "O"); + } + if (Optional.IsDefined(MinLastModifiedDateTime)) + { + writer.WritePropertyName("minLastModifiedDateTime"u8); + writer.WriteStringValue(MinLastModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(MaxLastModifiedDateTime)) + { + writer.WritePropertyName("maxLastModifiedDateTime"u8); + writer.WriteStringValue(MaxLastModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(MaxPageSize)) + { + writer.WritePropertyName("maxPageSize"u8); + writer.WriteNumberValue(MaxPageSize.Value); + } + if (Optional.IsDefined(SkipToken)) + { + writer.WritePropertyName("skipToken"u8); + writer.WriteStringValue(SkipToken); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + GetAllUnderCollectionRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetAllUnderCollectionRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetAllUnderCollectionRequest(document.RootElement, options); + } + + internal static GetAllUnderCollectionRequest DeserializeGetAllUnderCollectionRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList ownerItemIds = default; + IReadOnlyList dataFilters = default; + GeoJsonObject intersectsWithGeometry = default; + IReadOnlyList ids = default; + DateTimeOffset? minCreatedDateTime = default; + DateTimeOffset? maxCreatedDateTime = default; + DateTimeOffset? minLastModifiedDateTime = default; + DateTimeOffset? maxLastModifiedDateTime = default; + int? maxPageSize = default; + string skipToken = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ownerItemIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + ownerItemIds = array; + continue; + } + if (property.NameEquals("dataFilters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dataFilters = array; + continue; + } + if (property.NameEquals("intersectsWithGeometry"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intersectsWithGeometry = GeoJsonObject.DeserializeGeoJsonObject(property.Value, options); + continue; + } + if (property.NameEquals("ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + ids = array; + continue; + } + if (property.NameEquals("minCreatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minCreatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("maxCreatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxCreatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("minLastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minLastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("maxLastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxLastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("maxPageSize"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxPageSize = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("skipToken"u8)) + { + skipToken = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetAllUnderCollectionRequest( + ownerItemIds ?? new ChangeTrackingList(), + dataFilters ?? new ChangeTrackingList(), + intersectsWithGeometry, + ids ?? new ChangeTrackingList(), + minCreatedDateTime, + maxCreatedDateTime, + minLastModifiedDateTime, + maxLastModifiedDateTime, + maxPageSize, + skipToken, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GetAllUnderCollectionRequest)} does not support writing '{options.Format}' format."); + } + } + + GetAllUnderCollectionRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetAllUnderCollectionRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetAllUnderCollectionRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static GetAllUnderCollectionRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetAllUnderCollectionRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetAllUnderCollectionRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetAllUnderCollectionRequest.cs new file mode 100644 index 000000000000..cb7429f2cac5 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetAllUnderCollectionRequest.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The GetAllUnderCollectionRequest. + internal partial class GetAllUnderCollectionRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal GetAllUnderCollectionRequest() + { + OwnerItemIds = new ChangeTrackingList(); + DataFilters = new ChangeTrackingList(); + Ids = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Owner Item Ids of the resource. + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// Keeps track of any properties unknown to the library. + internal GetAllUnderCollectionRequest(IReadOnlyList ownerItemIds, IReadOnlyList dataFilters, GeoJsonObject intersectsWithGeometry, IReadOnlyList ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, IDictionary serializedAdditionalRawData) + { + OwnerItemIds = ownerItemIds; + DataFilters = dataFilters; + IntersectsWithGeometry = intersectsWithGeometry; + Ids = ids; + MinCreatedDateTime = minCreatedDateTime; + MaxCreatedDateTime = maxCreatedDateTime; + MinLastModifiedDateTime = minLastModifiedDateTime; + MaxLastModifiedDateTime = maxLastModifiedDateTime; + MaxPageSize = maxPageSize; + SkipToken = skipToken; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Owner Item Ids of the resource. + public IReadOnlyList OwnerItemIds { get; } + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + public IReadOnlyList DataFilters { get; } + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public GeoJsonObject IntersectsWithGeometry { get; } + /// Ids of the resource. + public IReadOnlyList Ids { get; } + /// Minimum creation date of resource (inclusive). + public DateTimeOffset? MinCreatedDateTime { get; } + /// Maximum creation date of resource (inclusive). + public DateTimeOffset? MaxCreatedDateTime { get; } + /// Minimum last modified date of resource (inclusive). + public DateTimeOffset? MinLastModifiedDateTime { get; } + /// Maximum last modified date of resource (inclusive). + public DateTimeOffset? MaxLastModifiedDateTime { get; } + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + public int? MaxPageSize { get; } + /// Skip token for getting next set of results. + public string SkipToken { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetDataRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetDataRequest.Serialization.cs new file mode 100644 index 000000000000..20cc5b995bba --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetDataRequest.Serialization.cs @@ -0,0 +1,270 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class GetDataRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetDataRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + writer.WritePropertyName("requestPath"u8); + writer.WriteStringValue(RequestPath); + writer.WritePropertyName("partnerRequestBody"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestBody) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + writer.WritePropertyName("partnerRequestHeaders"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestHeaders) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + writer.WritePropertyName("inputData"u8); + writer.WriteStartObject(); + foreach (var item in InputData) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + GetDataRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetDataRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetDataRequest(document.RootElement, options); + } + + internal static GetDataRequest DeserializeGetDataRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + string requestPath = default; + IReadOnlyDictionary partnerRequestBody = default; + IReadOnlyDictionary partnerRequestHeaders = default; + IReadOnlyDictionary inputData = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("solutionId"u8)) + { + solutionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestPath"u8)) + { + requestPath = property.Value.GetString(); + continue; + } + if (property.NameEquals("partnerRequestBody"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestBody = dictionary; + continue; + } + if (property.NameEquals("partnerRequestHeaders"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestHeaders = dictionary; + continue; + } + if (property.NameEquals("inputData"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + inputData = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetDataRequest( + solutionId, + requestPath, + partnerRequestBody, + partnerRequestHeaders, + inputData, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GetDataRequest)} does not support writing '{options.Format}' format."); + } + } + + GetDataRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetDataRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetDataRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static GetDataRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetDataRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetDataRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetDataRequest.cs new file mode 100644 index 000000000000..2ac08b41f2eb --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetDataRequest.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The GetDataRequest. + internal partial class GetDataRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// , , , or is null. + internal GetDataRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + Argument.AssertNotNull(inputData, nameof(inputData)); + + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + InputData = inputData; + } + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// Keeps track of any properties unknown to the library. + internal GetDataRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData, IDictionary serializedAdditionalRawData) + { + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + InputData = inputData; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GetDataRequest() + { + } + + /// SolutionId. + public string SolutionId { get; } + /// RequestPath. + public string RequestPath { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestBody { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestHeaders { get; } + /// + /// Input Data. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary InputData { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetJobRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetJobRequest.Serialization.cs new file mode 100644 index 000000000000..5d42ae6a808e --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetJobRequest.Serialization.cs @@ -0,0 +1,226 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class GetJobRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetJobRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + writer.WritePropertyName("requestPath"u8); + writer.WriteStringValue(RequestPath); + writer.WritePropertyName("partnerRequestBody"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestBody) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + writer.WritePropertyName("partnerRequestHeaders"u8); + writer.WriteStartObject(); + foreach (var item in PartnerRequestHeaders) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + GetJobRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetJobRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetJobRequest(document.RootElement, options); + } + + internal static GetJobRequest DeserializeGetJobRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + string requestPath = default; + IReadOnlyDictionary partnerRequestBody = default; + IReadOnlyDictionary partnerRequestHeaders = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("solutionId"u8)) + { + solutionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("requestPath"u8)) + { + requestPath = property.Value.GetString(); + continue; + } + if (property.NameEquals("partnerRequestBody"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestBody = dictionary; + continue; + } + if (property.NameEquals("partnerRequestHeaders"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + partnerRequestHeaders = dictionary; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetJobRequest(solutionId, requestPath, partnerRequestBody, partnerRequestHeaders, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GetJobRequest)} does not support writing '{options.Format}' format."); + } + } + + GetJobRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetJobRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetJobRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static GetJobRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetJobRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetJobRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetJobRequest.cs new file mode 100644 index 000000000000..8f50fc9264c1 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetJobRequest.cs @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The GetJobRequest. + internal partial class GetJobRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// , , or is null. + internal GetJobRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + } + + /// Initializes a new instance of . + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Keeps track of any properties unknown to the library. + internal GetJobRequest(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IDictionary serializedAdditionalRawData) + { + SolutionId = solutionId; + RequestPath = requestPath; + PartnerRequestBody = partnerRequestBody; + PartnerRequestHeaders = partnerRequestHeaders; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GetJobRequest() + { + } + + /// SolutionId. + public string SolutionId { get; } + /// RequestPath. + public string RequestPath { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestBody { get; } + /// + /// Properties. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary PartnerRequestHeaders { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetRequest.Serialization.cs new file mode 100644 index 000000000000..1064366969c5 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetRequest.Serialization.cs @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class GetRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetRequest)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("providerName"u8); + writer.WriteStringValue(ProviderName); + writer.WritePropertyName("providerApiName"u8); + writer.WriteStringValue(ProviderApiName); + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + writer.WritePropertyName("units"u8); + writer.WriteStringValue(Units); + if (Optional.IsDefined(Credentials)) + { + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + } + if (Optional.IsCollectionDefined(Locations)) + { + writer.WritePropertyName("locations"u8); + writer.WriteStartArray(); + foreach (var item in Locations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + GetRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GetRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGetRequest(document.RootElement, options); + } + + internal static GetRequest DeserializeGetRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string providerName = default; + string providerApiName = default; + string language = default; + string units = default; + ApiKeyAuthCredentials credentials = default; + IReadOnlyList locations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("providerName"u8)) + { + providerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("providerApiName"u8)) + { + providerApiName = property.Value.GetString(); + continue; + } + if (property.NameEquals("language"u8)) + { + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("units"u8)) + { + units = property.Value.GetString(); + continue; + } + if (property.NameEquals("credentials"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + credentials = ApiKeyAuthCredentials.DeserializeApiKeyAuthCredentials(property.Value, options); + continue; + } + if (property.NameEquals("locations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WeatherLocation.DeserializeWeatherLocation(item, options)); + } + locations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new GetRequest( + providerName, + providerApiName, + language, + units, + credentials, + locations ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GetRequest)} does not support writing '{options.Format}' format."); + } + } + + GetRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GetRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static GetRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGetRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetRequest.cs new file mode 100644 index 000000000000..5a60b13376af --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/GetRequest.cs @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The GetRequest. + internal partial class GetRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Weather provider name. + /// Provider's api name to which request is to be made. + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + /// , or is null. + internal GetRequest(string providerName, string providerApiName, string units) + { + Argument.AssertNotNull(providerName, nameof(providerName)); + Argument.AssertNotNull(providerApiName, nameof(providerApiName)); + Argument.AssertNotNull(units, nameof(units)); + + ProviderName = providerName; + ProviderApiName = providerApiName; + Units = units; + Locations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Weather provider name. + /// Provider's api name to which request is to be made. + /// + /// Language (IETF BCP 47 language tag) in which search results should be returned + /// by the data provider. Examples: 'en-US', 'es', 'es-MX', 'fr-FR'. + /// + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + /// Api Key Auth Credentials class for API Key based Auth. + /// List of locations for which weather data need to be fetched from the provider. + /// Keeps track of any properties unknown to the library. + internal GetRequest(string providerName, string providerApiName, string language, string units, ApiKeyAuthCredentials credentials, IReadOnlyList locations, IDictionary serializedAdditionalRawData) + { + ProviderName = providerName; + ProviderApiName = providerApiName; + Language = language; + Units = units; + Credentials = credentials; + Locations = locations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal GetRequest() + { + } + + /// Weather provider name. + public string ProviderName { get; } + /// Provider's api name to which request is to be made. + public string ProviderApiName { get; } + /// + /// Language (IETF BCP 47 language tag) in which search results should be returned + /// by the data provider. Examples: 'en-US', 'es', 'es-MX', 'fr-FR'. + /// + public string Language { get; } + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + public string Units { get; } + /// Api Key Auth Credentials class for API Key based Auth. + public ApiKeyAuthCredentials Credentials { get; } + /// List of locations for which weather data need to be fetched from the provider. + public IReadOnlyList Locations { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFile.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFile.Serialization.cs new file mode 100644 index 000000000000..24cb17bacb73 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFile.Serialization.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class ImageFile : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageFile)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(FilePath)) + { + writer.WritePropertyName("filePath"u8); + writer.WriteStringValue(FilePath); + } + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + if (Optional.IsDefined(ImageFormat)) + { + writer.WritePropertyName("imageFormat"u8); + writer.WriteStringValue(ImageFormat.Value.ToString()); + } + if (Optional.IsDefined(Resolution)) + { + writer.WritePropertyName("resolution"u8); + writer.WriteNumberValue(Resolution.Value); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ImageFile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ImageFile)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeImageFile(document.RootElement, options); + } + + internal static ImageFile DeserializeImageFile(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string filePath = default; + string name = default; + ImageFormat? imageFormat = default; + double? resolution = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("filePath"u8)) + { + filePath = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("imageFormat"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + imageFormat = new ImageFormat(property.Value.GetString()); + continue; + } + if (property.NameEquals("resolution"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resolution = property.Value.GetDouble(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ImageFile(filePath, name, imageFormat, resolution, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ImageFile)} does not support writing '{options.Format}' format."); + } + } + + ImageFile IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeImageFile(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ImageFile)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ImageFile FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeImageFile(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFile.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFile.cs new file mode 100644 index 000000000000..4556533152d4 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFile.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema of image file resource. + public partial class ImageFile + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Name of the image file. + /// is null. + internal ImageFile(string name) + { + Argument.AssertNotNull(name, nameof(name)); + + Name = name; + } + + /// Initializes a new instance of . + /// ADLS path of the image file. + /// Name of the image file. + /// Supported image formats for scene resource. + /// Resolution of image file in meters. + /// Keeps track of any properties unknown to the library. + internal ImageFile(string filePath, string name, ImageFormat? imageFormat, double? resolution, IDictionary serializedAdditionalRawData) + { + FilePath = filePath; + Name = name; + ImageFormat = imageFormat; + Resolution = resolution; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ImageFile() + { + } + + /// ADLS path of the image file. + public string FilePath { get; } + /// Name of the image file. + public string Name { get; } + /// Supported image formats for scene resource. + public ImageFormat? ImageFormat { get; } + /// Resolution of image file in meters. + public double? Resolution { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFormat.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFormat.cs new file mode 100644 index 000000000000..fef23884cbdb --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ImageFormat.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AgriculturePlatform +{ + /// Supported image formats for scene resource. + public readonly partial struct ImageFormat : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public ImageFormat(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string TIFValue = "TIF"; + + /// TIF. + public static ImageFormat TIF { get; } = new ImageFormat(TIFValue); + /// Determines if two values are the same. + public static bool operator ==(ImageFormat left, ImageFormat right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(ImageFormat left, ImageFormat right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator ImageFormat(string value) => new ImageFormat(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is ImageFormat other && Equals(other); + /// + public bool Equals(ImageFormat other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Argument.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Argument.cs new file mode 100644 index 000000000000..74478b58d1db --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Argument.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + internal static class Argument + { + public static void AssertNotNull(T value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNull(T? value, string name) + where T : struct + { + if (!value.HasValue) + { + throw new ArgumentNullException(name); + } + } + + public static void AssertNotNullOrEmpty(IEnumerable value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value is ICollection collectionOfT && collectionOfT.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + if (value is ICollection collection && collection.Count == 0) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + using IEnumerator e = value.GetEnumerator(); + if (!e.MoveNext()) + { + throw new ArgumentException("Value cannot be an empty collection.", name); + } + } + + public static void AssertNotNullOrEmpty(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (value.Length == 0) + { + throw new ArgumentException("Value cannot be an empty string.", name); + } + } + + public static void AssertNotNullOrWhiteSpace(string value, string name) + { + if (value is null) + { + throw new ArgumentNullException(name); + } + if (string.IsNullOrWhiteSpace(value)) + { + throw new ArgumentException("Value cannot be empty or contain only white-space characters.", name); + } + } + + public static void AssertNotDefault(ref T value, string name) + where T : struct, IEquatable + { + if (value.Equals(default)) + { + throw new ArgumentException("Value cannot be empty.", name); + } + } + + public static void AssertInRange(T value, T minimum, T maximum, string name) + where T : notnull, IComparable + { + if (minimum.CompareTo(value) > 0) + { + throw new ArgumentOutOfRangeException(name, "Value is less than the minimum allowed."); + } + if (maximum.CompareTo(value) < 0) + { + throw new ArgumentOutOfRangeException(name, "Value is greater than the maximum allowed."); + } + } + + public static void AssertEnumDefined(Type enumType, object value, string name) + { + if (!Enum.IsDefined(enumType, value)) + { + throw new ArgumentException($"Value not defined for {enumType.FullName}.", name); + } + } + + public static T CheckNotNull(T value, string name) + where T : class + { + AssertNotNull(value, name); + return value; + } + + public static string CheckNotNullOrEmpty(string value, string name) + { + AssertNotNullOrEmpty(value, name); + return value; + } + + public static void AssertNull(T value, string name, string message = null) + { + if (value != null) + { + throw new ArgumentException(message ?? "Value must be null.", name); + } + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ChangeTrackingDictionary.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ChangeTrackingDictionary.cs new file mode 100644 index 000000000000..90e9eeaa6ae0 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ChangeTrackingDictionary.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + internal class ChangeTrackingDictionary : IDictionary, IReadOnlyDictionary where TKey : notnull + { + private IDictionary _innerDictionary; + + public ChangeTrackingDictionary() + { + } + + public ChangeTrackingDictionary(IDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(dictionary); + } + + public ChangeTrackingDictionary(IReadOnlyDictionary dictionary) + { + if (dictionary == null) + { + return; + } + _innerDictionary = new Dictionary(); + foreach (var pair in dictionary) + { + _innerDictionary.Add(pair); + } + } + + public bool IsUndefined => _innerDictionary == null; + + public int Count => IsUndefined ? 0 : EnsureDictionary().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureDictionary().IsReadOnly; + + public ICollection Keys => IsUndefined ? Array.Empty() : EnsureDictionary().Keys; + + public ICollection Values => IsUndefined ? Array.Empty() : EnsureDictionary().Values; + + public TValue this[TKey key] + { + get + { + if (IsUndefined) + { + throw new KeyNotFoundException(nameof(key)); + } + return EnsureDictionary()[key]; + } + set + { + EnsureDictionary()[key] = value; + } + } + + IEnumerable IReadOnlyDictionary.Keys => Keys; + + IEnumerable IReadOnlyDictionary.Values => Values; + + public IEnumerator> GetEnumerator() + { + if (IsUndefined) + { + IEnumerator> enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureDictionary().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(KeyValuePair item) + { + EnsureDictionary().Add(item); + } + + public void Clear() + { + EnsureDictionary().Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Contains(item); + } + + public void CopyTo(KeyValuePair[] array, int index) + { + if (IsUndefined) + { + return; + } + EnsureDictionary().CopyTo(array, index); + } + + public bool Remove(KeyValuePair item) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(item); + } + + public void Add(TKey key, TValue value) + { + EnsureDictionary().Add(key, value); + } + + public bool ContainsKey(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().ContainsKey(key); + } + + public bool Remove(TKey key) + { + if (IsUndefined) + { + return false; + } + return EnsureDictionary().Remove(key); + } + + public bool TryGetValue(TKey key, out TValue value) + { + if (IsUndefined) + { + value = default; + return false; + } + return EnsureDictionary().TryGetValue(key, out value); + } + + public IDictionary EnsureDictionary() + { + return _innerDictionary ??= new Dictionary(); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ChangeTrackingList.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ChangeTrackingList.cs new file mode 100644 index 000000000000..44d1e576d6b0 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ChangeTrackingList.cs @@ -0,0 +1,153 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + internal class ChangeTrackingList : IList, IReadOnlyList + { + private IList _innerList; + + public ChangeTrackingList() + { + } + + public ChangeTrackingList(IList innerList) + { + if (innerList != null) + { + _innerList = innerList; + } + } + + public ChangeTrackingList(IReadOnlyList innerList) + { + if (innerList != null) + { + _innerList = innerList.ToList(); + } + } + + public bool IsUndefined => _innerList == null; + + public int Count => IsUndefined ? 0 : EnsureList().Count; + + public bool IsReadOnly => IsUndefined ? false : EnsureList().IsReadOnly; + + public T this[int index] + { + get + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + return EnsureList()[index]; + } + set + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList()[index] = value; + } + } + + public void Reset() + { + _innerList = null; + } + + public IEnumerator GetEnumerator() + { + if (IsUndefined) + { + IEnumerator enumerateEmpty() + { + yield break; + } + return enumerateEmpty(); + } + return EnsureList().GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void Add(T item) + { + EnsureList().Add(item); + } + + public void Clear() + { + EnsureList().Clear(); + } + + public bool Contains(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Contains(item); + } + + public void CopyTo(T[] array, int arrayIndex) + { + if (IsUndefined) + { + return; + } + EnsureList().CopyTo(array, arrayIndex); + } + + public bool Remove(T item) + { + if (IsUndefined) + { + return false; + } + return EnsureList().Remove(item); + } + + public int IndexOf(T item) + { + if (IsUndefined) + { + return -1; + } + return EnsureList().IndexOf(item); + } + + public void Insert(int index, T item) + { + EnsureList().Insert(index, item); + } + + public void RemoveAt(int index) + { + if (IsUndefined) + { + throw new ArgumentOutOfRangeException(nameof(index)); + } + EnsureList().RemoveAt(index); + } + + public IList EnsureList() + { + return _innerList ??= new List(); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ModelSerializationExtensions.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ModelSerializationExtensions.cs new file mode 100644 index 000000000000..b17387b30e18 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/ModelSerializationExtensions.cs @@ -0,0 +1,399 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.Text.Json; +using System.Xml; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal static class ModelSerializationExtensions + { + internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; + internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); + + public static object GetObject(this JsonElement element) + { + switch (element.ValueKind) + { + case JsonValueKind.String: + return element.GetString(); + case JsonValueKind.Number: + if (element.TryGetInt32(out int intValue)) + { + return intValue; + } + if (element.TryGetInt64(out long longValue)) + { + return longValue; + } + return element.GetDouble(); + case JsonValueKind.True: + return true; + case JsonValueKind.False: + return false; + case JsonValueKind.Undefined: + case JsonValueKind.Null: + return null; + case JsonValueKind.Object: + var dictionary = new Dictionary(); + foreach (var jsonProperty in element.EnumerateObject()) + { + dictionary.Add(jsonProperty.Name, jsonProperty.Value.GetObject()); + } + return dictionary; + case JsonValueKind.Array: + var list = new List(); + foreach (var item in element.EnumerateArray()) + { + list.Add(item.GetObject()); + } + return list.ToArray(); + default: + throw new NotSupportedException($"Not supported value kind {element.ValueKind}"); + } + } + + public static byte[] GetBytesFromBase64(this JsonElement element, string format) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + + return format switch + { + "U" => TypeFormatters.FromBase64UrlString(element.GetRequiredString()), + "D" => element.GetBytesFromBase64(), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + } + + public static DateTimeOffset GetDateTimeOffset(this JsonElement element, string format) => format switch + { + "U" when element.ValueKind == JsonValueKind.Number => DateTimeOffset.FromUnixTimeSeconds(element.GetInt64()), + _ => TypeFormatters.ParseDateTimeOffset(element.GetString(), format) + }; + + public static TimeSpan GetTimeSpan(this JsonElement element, string format) => TypeFormatters.ParseTimeSpan(element.GetString(), format); + + public static char GetChar(this JsonElement element) + { + if (element.ValueKind == JsonValueKind.String) + { + var text = element.GetString(); + if (text == null || text.Length != 1) + { + throw new NotSupportedException($"Cannot convert \"{text}\" to a char"); + } + return text[0]; + } + else + { + throw new NotSupportedException($"Cannot convert {element.ValueKind} to a char"); + } + } + + [Conditional("DEBUG")] + public static void ThrowNonNullablePropertyIsNull(this JsonProperty property) + { + throw new JsonException($"A property '{property.Name}' defined as non-nullable but received as null from the service. This exception only happens in DEBUG builds of the library and would be ignored in the release build"); + } + + public static string GetRequiredString(this JsonElement element) + { + var value = element.GetString(); + if (value == null) + { + throw new InvalidOperationException($"The requested operation requires an element of type 'String', but the target element has type '{element.ValueKind}'."); + } + return value; + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, DateTime value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, TimeSpan value, string format) + { + writer.WriteStringValue(TypeFormatters.ToString(value, format)); + } + + public static void WriteStringValue(this Utf8JsonWriter writer, char value) + { + writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); + } + + public static void WriteBase64StringValue(this Utf8JsonWriter writer, byte[] value, string format) + { + if (value == null) + { + writer.WriteNullValue(); + return; + } + switch (format) + { + case "U": + writer.WriteStringValue(TypeFormatters.ToBase64UrlString(value)); + break; + case "D": + writer.WriteBase64StringValue(value); + break; + default: + throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)); + } + } + + public static void WriteNumberValue(this Utf8JsonWriter writer, DateTimeOffset value, string format) + { + if (format != "U") + { + throw new ArgumentOutOfRangeException(nameof(format), "Only 'U' format is supported when writing a DateTimeOffset as a Number."); + } + writer.WriteNumberValue(value.ToUnixTimeSeconds()); + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, T value, ModelReaderWriterOptions options = null) + { + switch (value) + { + case null: + writer.WriteNullValue(); + break; + case IJsonModel jsonModel: + jsonModel.Write(writer, options ?? WireOptions); + break; + case IUtf8JsonSerializable serializable: + serializable.Write(writer); + break; + case byte[] bytes: + writer.WriteBase64StringValue(bytes); + break; + case BinaryData bytes0: + writer.WriteBase64StringValue(bytes0); + break; + case JsonElement json: + json.WriteTo(writer); + break; + case int i: + writer.WriteNumberValue(i); + break; + case decimal d: + writer.WriteNumberValue(d); + break; + case double d0: + if (double.IsNaN(d0)) + { + writer.WriteStringValue("NaN"); + } + else + { + writer.WriteNumberValue(d0); + } + break; + case float f: + writer.WriteNumberValue(f); + break; + case long l: + writer.WriteNumberValue(l); + break; + case string s: + writer.WriteStringValue(s); + break; + case bool b: + writer.WriteBooleanValue(b); + break; + case Guid g: + writer.WriteStringValue(g); + break; + case DateTimeOffset dateTimeOffset: + writer.WriteStringValue(dateTimeOffset, "O"); + break; + case DateTime dateTime: + writer.WriteStringValue(dateTime, "O"); + break; + case IEnumerable> enumerable: + writer.WriteStartObject(); + foreach (var pair in enumerable) + { + writer.WritePropertyName(pair.Key); + writer.WriteObjectValue(pair.Value, options); + } + writer.WriteEndObject(); + break; + case IEnumerable objectEnumerable: + writer.WriteStartArray(); + foreach (var item in objectEnumerable) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + break; + case TimeSpan timeSpan: + writer.WriteStringValue(timeSpan, "P"); + break; + default: + throw new NotSupportedException($"Not supported type {value.GetType()}"); + } + } + + public static void WriteObjectValue(this Utf8JsonWriter writer, object value, ModelReaderWriterOptions options = null) + { + writer.WriteObjectValue(value, options); + } + + internal static class TypeFormatters + { + private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; + public const string DefaultNumberFormat = "G"; + + public static string ToString(bool value) => value ? "true" : "false"; + + public static string ToString(DateTime value, string format) => value.Kind switch + { + DateTimeKind.Utc => ToString((DateTimeOffset)value, format), + _ => throw new NotSupportedException($"DateTime {value} has a Kind of {value.Kind}. Azure SDK requires it to be UTC. You can call DateTime.SpecifyKind to change Kind property value to DateTimeKind.Utc.") + }; + + public static string ToString(DateTimeOffset value, string format) => format switch + { + "D" => value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), + "U" => value.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture), + "O" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "o" => value.ToUniversalTime().ToString(RoundtripZFormat, CultureInfo.InvariantCulture), + "R" => value.ToString("r", CultureInfo.InvariantCulture), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(TimeSpan value, string format) => format switch + { + "P" => XmlConvert.ToString(value), + _ => value.ToString(format, CultureInfo.InvariantCulture) + }; + + public static string ToString(byte[] value, string format) => format switch + { + "U" => ToBase64UrlString(value), + "D" => Convert.ToBase64String(value), + _ => throw new ArgumentException($"Format is not supported: '{format}'", nameof(format)) + }; + + public static string ToBase64UrlString(byte[] value) + { + int numWholeOrPartialInputBlocks = checked(value.Length + 2) / 3; + int size = checked(numWholeOrPartialInputBlocks * 4); + char[] output = new char[size]; + + int numBase64Chars = Convert.ToBase64CharArray(value, 0, value.Length, output, 0); + + int i = 0; + for (; i < numBase64Chars; i++) + { + char ch = output[i]; + if (ch == '+') + { + output[i] = '-'; + } + else + { + if (ch == '/') + { + output[i] = '_'; + } + else + { + if (ch == '=') + { + break; + } + } + } + } + + return new string(output, 0, i); + } + + public static byte[] FromBase64UrlString(string value) + { + int paddingCharsToAdd = (value.Length % 4) switch + { + 0 => 0, + 2 => 2, + 3 => 1, + _ => throw new InvalidOperationException("Malformed input") + }; + char[] output = new char[(value.Length + paddingCharsToAdd)]; + int i = 0; + for (; i < value.Length; i++) + { + char ch = value[i]; + if (ch == '-') + { + output[i] = '+'; + } + else + { + if (ch == '_') + { + output[i] = '/'; + } + else + { + output[i] = ch; + } + } + } + + for (; i < output.Length; i++) + { + output[i] = '='; + } + + return Convert.FromBase64CharArray(output, 0, output.Length); + } + + public static DateTimeOffset ParseDateTimeOffset(string value, string format) => format switch + { + "U" => DateTimeOffset.FromUnixTimeSeconds(long.Parse(value, CultureInfo.InvariantCulture)), + _ => DateTimeOffset.Parse(value, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal) + }; + + public static TimeSpan ParseTimeSpan(string value, string format) => format switch + { + "P" => XmlConvert.ToTimeSpan(value), + _ => TimeSpan.ParseExact(value, format, CultureInfo.InvariantCulture) + }; + + public static string ConvertToString(object value, string format = null) => value switch + { + null => "null", + string s => s, + bool b => ToString(b), + int or float or double or long or decimal => ((IFormattable)value).ToString(DefaultNumberFormat, CultureInfo.InvariantCulture), + byte[] b0 when format != null => ToString(b0, format), + IEnumerable s0 => string.Join(",", s0), + DateTimeOffset dateTime when format != null => ToString(dateTime, format), + TimeSpan timeSpan when format != null => ToString(timeSpan, format), + TimeSpan timeSpan0 => XmlConvert.ToString(timeSpan0), + Guid guid => guid.ToString(), + BinaryData binaryData => ConvertToString(binaryData.ToArray(), format), + _ => value.ToString() + }; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Optional.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Optional.cs new file mode 100644 index 000000000000..fb3d71cc2578 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Optional.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; + +namespace Azure.AgriculturePlatform +{ + internal static class Optional + { + public static bool IsCollectionDefined(IEnumerable collection) + { + return !(collection is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined); + } + + public static bool IsCollectionDefined(IDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsCollectionDefined(IReadOnlyDictionary collection) + { + return !(collection is ChangeTrackingDictionary changeTrackingDictionary && changeTrackingDictionary.IsUndefined); + } + + public static bool IsDefined(T? value) + where T : struct + { + return value.HasValue; + } + + public static bool IsDefined(object value) + { + return value != null; + } + + public static bool IsDefined(JsonElement value) + { + return value.ValueKind != JsonValueKind.Undefined; + } + + public static bool IsDefined(string value) + { + return value != null; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Utf8JsonRequestContent.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Utf8JsonRequestContent.cs new file mode 100644 index 000000000000..18c02e34fe7e --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Internal/Utf8JsonRequestContent.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.IO; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal class Utf8JsonRequestContent : RequestContent + { + private readonly MemoryStream _stream; + private readonly RequestContent _content; + + public Utf8JsonRequestContent() + { + _stream = new MemoryStream(); + _content = Create(_stream); + JsonWriter = new Utf8JsonWriter(_stream); + } + + public Utf8JsonWriter JsonWriter { get; } + + public override async Task WriteToAsync(Stream stream, CancellationToken cancellationToken = default) + { + await JsonWriter.FlushAsync().ConfigureAwait(false); + await _content.WriteToAsync(stream, cancellationToken).ConfigureAwait(false); + } + + public override void WriteTo(Stream stream, CancellationToken cancellationToken = default) + { + JsonWriter.Flush(); + _content.WriteTo(stream, cancellationToken); + } + + public override bool TryComputeLength(out long length) + { + length = JsonWriter.BytesCommitted + JsonWriter.BytesPending; + return true; + } + + public override void Dispose() + { + JsonWriter.Dispose(); + _content.Dispose(); + _stream.Dispose(); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Item.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Item.Serialization.cs new file mode 100644 index 000000000000..b84af43a19bc --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Item.Serialization.cs @@ -0,0 +1,436 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Item : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Item)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Links)) + { + writer.WritePropertyName("links"u8); + writer.WriteStartArray(); + foreach (var item in Links) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("eTag"u8); + writer.WriteStringValue(ETag); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedDateTime)) + { + writer.WritePropertyName("modifiedDateTime"u8); + writer.WriteStringValue(ModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedBy)) + { + writer.WritePropertyName("modifiedBy"u8); + writer.WriteStringValue(ModifiedBy); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + writer.WritePropertyName("data"u8); + writer.WriteStartObject(); + foreach (var item in Data) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (Optional.IsDefined(OwnerItemId)) + { + writer.WritePropertyName("ownerItemId"u8); + writer.WriteStringValue(OwnerItemId); + } + if (options.Format != "W" && Optional.IsDefined(CatalogId)) + { + writer.WritePropertyName("catalogId"u8); + writer.WriteStringValue(CatalogId); + } + if (options.Format != "W" && Optional.IsDefined(CollectionId)) + { + writer.WritePropertyName("collectionId"u8); + writer.WriteStringValue(CollectionId); + } + if (Optional.IsCollectionDefined(Assets)) + { + writer.WritePropertyName("assets"u8); + writer.WriteStartArray(); + foreach (var item in Assets) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Item IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Item)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeItem(document.RootElement, options); + } + + internal static Item DeserializeItem(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList links = default; + string eTag = default; + string status = default; + DateTimeOffset? createdDateTime = default; + DateTimeOffset? modifiedDateTime = default; + string source = default; + string name = default; + string description = default; + string createdBy = default; + string modifiedBy = default; + IDictionary properties = default; + IDictionary data = default; + string ownerItemId = default; + string catalogId = default; + string collectionId = default; + IList assets = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("links"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Link.DeserializeLink(item, options)); + } + links = array; + continue; + } + if (property.NameEquals("eTag"u8)) + { + eTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("modifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedBy"u8)) + { + modifiedBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + properties = dictionary; + continue; + } + if (property.NameEquals("data"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + data = dictionary; + continue; + } + if (property.NameEquals("ownerItemId"u8)) + { + ownerItemId = property.Value.GetString(); + continue; + } + if (property.NameEquals("catalogId"u8)) + { + catalogId = property.Value.GetString(); + continue; + } + if (property.NameEquals("collectionId"u8)) + { + collectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("assets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Asset.DeserializeAsset(item, options)); + } + assets = array; + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Item( + links ?? new ChangeTrackingList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties ?? new ChangeTrackingDictionary(), + data, + ownerItemId, + catalogId, + collectionId, + assets ?? new ChangeTrackingList(), + id, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Item)} does not support writing '{options.Format}' format."); + } + } + + Item IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Item)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Item FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeItem(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Item.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Item.cs new file mode 100644 index 000000000000..9b9d44031a9a --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Item.cs @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Item. + public partial class Item + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Schema for records under the dataset. + /// is null. + public Item(IDictionary data) + { + Argument.AssertNotNull(data, nameof(data)); + + Links = new ChangeTrackingList(); + Properties = new ChangeTrackingDictionary(); + Data = data; + Assets = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Schema for records under the dataset. + /// Owner Item Ids of the resource. + /// Id of the Catalog resource. + /// Id of the Collection resource. + /// Assets. + /// Id of the Item. + /// Keeps track of any properties unknown to the library. + internal Item(IList links, string eTag, string status, DateTimeOffset? createdDateTime, DateTimeOffset? modifiedDateTime, string source, string name, string description, string createdBy, string modifiedBy, IDictionary properties, IDictionary data, string ownerItemId, string catalogId, string collectionId, IList assets, string id, IDictionary serializedAdditionalRawData) + { + Links = links; + ETag = eTag; + Status = status; + CreatedDateTime = createdDateTime; + ModifiedDateTime = modifiedDateTime; + Source = source; + Name = name; + Description = description; + CreatedBy = createdBy; + ModifiedBy = modifiedBy; + Properties = properties; + Data = data; + OwnerItemId = ownerItemId; + CatalogId = catalogId; + CollectionId = collectionId; + Assets = assets; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Item() + { + } + + /// Links for referencing other objects. + public IList Links { get; } + /// The ETag value to implement optimistic concurrency. + public string ETag { get; } + /// Status of the resource. + public string Status { get; set; } + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? CreatedDateTime { get; } + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? ModifiedDateTime { get; } + /// Source of the resource. + public string Source { get; set; } + /// Name to identify resource. + public string Name { get; set; } + /// Textual description of the resource. + public string Description { get; set; } + /// Created by user/tenant id. + public string CreatedBy { get; } + /// Modified by user/tenant id. + public string ModifiedBy { get; } + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary Properties { get; } + /// + /// Schema for records under the dataset. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary Data { get; } + /// Owner Item Ids of the resource. + public string OwnerItemId { get; set; } + /// Id of the Catalog resource. + public string CatalogId { get; } + /// Id of the Collection resource. + public string CollectionId { get; } + /// Assets. + public IList Assets { get; } + /// Id of the Item. + public string Id { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemListResponse.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemListResponse.Serialization.cs new file mode 100644 index 000000000000..82235e647c69 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemListResponse.Serialization.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class ItemListResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ItemListResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (Optional.IsDefined(SkipToken)) + { + writer.WritePropertyName("skipToken"u8); + writer.WriteStringValue(SkipToken); + } + if (Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ItemListResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ItemListResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeItemListResponse(document.RootElement, options); + } + + internal static ItemListResponse DeserializeItemListResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + string skipToken = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Item.DeserializeItem(item, options)); + } + value = array; + continue; + } + if (property.NameEquals("skipToken"u8)) + { + skipToken = property.Value.GetString(); + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ItemListResponse(value, skipToken, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ItemListResponse)} does not support writing '{options.Format}' format."); + } + } + + ItemListResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeItemListResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ItemListResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ItemListResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeItemListResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemListResponse.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemListResponse.cs new file mode 100644 index 000000000000..ac09b7bbbccf --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemListResponse.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + /// Represents a response containing a list of items. + public partial class ItemListResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// List of Items. + /// is null. + internal ItemListResponse(IEnumerable value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value.ToList(); + } + + /// Initializes a new instance of . + /// List of Items. + /// Skip token for getting next set of results. + /// + /// URL to do the POST request with same filters, + /// to get next set of items. + /// + /// Keeps track of any properties unknown to the library. + internal ItemListResponse(IReadOnlyList value, string skipToken, string nextLink, IDictionary serializedAdditionalRawData) + { + Value = value; + SkipToken = skipToken; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ItemListResponse() + { + } + + /// List of Items. + public IReadOnlyList Value { get; } + /// Skip token for getting next set of results. + public string SkipToken { get; } + /// + /// URL to do the POST request with same filters, + /// to get next set of items. + /// + public string NextLink { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemResponse.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemResponse.Serialization.cs new file mode 100644 index 000000000000..753d6aa9d8f8 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemResponse.Serialization.cs @@ -0,0 +1,436 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class ItemResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ItemResponse)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Links)) + { + writer.WritePropertyName("links"u8); + writer.WriteStartArray(); + foreach (var item in Links) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("eTag"u8); + writer.WriteStringValue(ETag); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedDateTime)) + { + writer.WritePropertyName("modifiedDateTime"u8); + writer.WriteStringValue(ModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedBy)) + { + writer.WritePropertyName("modifiedBy"u8); + writer.WriteStringValue(ModifiedBy); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + writer.WritePropertyName("data"u8); + writer.WriteStartObject(); + foreach (var item in Data) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (Optional.IsDefined(OwnerItemId)) + { + writer.WritePropertyName("ownerItemId"u8); + writer.WriteStringValue(OwnerItemId); + } + if (options.Format != "W" && Optional.IsDefined(CatalogId)) + { + writer.WritePropertyName("catalogId"u8); + writer.WriteStringValue(CatalogId); + } + if (options.Format != "W" && Optional.IsDefined(CollectionId)) + { + writer.WritePropertyName("collectionId"u8); + writer.WriteStringValue(CollectionId); + } + if (Optional.IsCollectionDefined(Assets)) + { + writer.WritePropertyName("assets"u8); + writer.WriteStartArray(); + foreach (var item in Assets) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + ItemResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(ItemResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeItemResponse(document.RootElement, options); + } + + internal static ItemResponse DeserializeItemResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList links = default; + string eTag = default; + string status = default; + DateTimeOffset? createdDateTime = default; + DateTimeOffset? modifiedDateTime = default; + string source = default; + string name = default; + string description = default; + string createdBy = default; + string modifiedBy = default; + IReadOnlyDictionary properties = default; + IReadOnlyDictionary data = default; + string ownerItemId = default; + string catalogId = default; + string collectionId = default; + IReadOnlyList assets = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("links"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Link.DeserializeLink(item, options)); + } + links = array; + continue; + } + if (property.NameEquals("eTag"u8)) + { + eTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("modifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedBy"u8)) + { + modifiedBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + properties = dictionary; + continue; + } + if (property.NameEquals("data"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + data = dictionary; + continue; + } + if (property.NameEquals("ownerItemId"u8)) + { + ownerItemId = property.Value.GetString(); + continue; + } + if (property.NameEquals("catalogId"u8)) + { + catalogId = property.Value.GetString(); + continue; + } + if (property.NameEquals("collectionId"u8)) + { + collectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("assets"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Asset.DeserializeAsset(item, options)); + } + assets = array; + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new ItemResponse( + links ?? new ChangeTrackingList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties ?? new ChangeTrackingDictionary(), + data, + ownerItemId, + catalogId, + collectionId, + assets ?? new ChangeTrackingList(), + id, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(ItemResponse)} does not support writing '{options.Format}' format."); + } + } + + ItemResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeItemResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(ItemResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static ItemResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeItemResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemResponse.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemResponse.cs new file mode 100644 index 000000000000..54ef423d85ec --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/ItemResponse.cs @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// ItemResponse model for Items api. + public partial class ItemResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Schema for records under the dataset. + /// is null. + internal ItemResponse(IReadOnlyDictionary data) + { + Argument.AssertNotNull(data, nameof(data)); + + Links = new ChangeTrackingList(); + Properties = new ChangeTrackingDictionary(); + Data = data; + Assets = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Schema for records under the dataset. + /// OwnerItemId. + /// CatalogId. + /// CollectionId. + /// Assets. + /// Unique resource ID. + /// Keeps track of any properties unknown to the library. + internal ItemResponse(IReadOnlyList links, string eTag, string status, DateTimeOffset? createdDateTime, DateTimeOffset? modifiedDateTime, string source, string name, string description, string createdBy, string modifiedBy, IReadOnlyDictionary properties, IReadOnlyDictionary data, string ownerItemId, string catalogId, string collectionId, IReadOnlyList assets, string id, IDictionary serializedAdditionalRawData) + { + Links = links; + ETag = eTag; + Status = status; + CreatedDateTime = createdDateTime; + ModifiedDateTime = modifiedDateTime; + Source = source; + Name = name; + Description = description; + CreatedBy = createdBy; + ModifiedBy = modifiedBy; + Properties = properties; + Data = data; + OwnerItemId = ownerItemId; + CatalogId = catalogId; + CollectionId = collectionId; + Assets = assets; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal ItemResponse() + { + } + + /// Links for referencing other objects. + public IReadOnlyList Links { get; } + /// The ETag value to implement optimistic concurrency. + public string ETag { get; } + /// Status of the resource. + public string Status { get; } + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? CreatedDateTime { get; } + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? ModifiedDateTime { get; } + /// Source of the resource. + public string Source { get; } + /// Name to identify resource. + public string Name { get; } + /// Textual description of the resource. + public string Description { get; } + /// Created by user/tenant id. + public string CreatedBy { get; } + /// Modified by user/tenant id. + public string ModifiedBy { get; } + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary Properties { get; } + /// + /// Schema for records under the dataset. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary Data { get; } + /// OwnerItemId. + public string OwnerItemId { get; } + /// CatalogId. + public string CatalogId { get; } + /// CollectionId. + public string CollectionId { get; } + /// Assets. + public IReadOnlyList Assets { get; } + /// Unique resource ID. + public string Id { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Items.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Items.cs new file mode 100644 index 000000000000..944870435d93 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Items.cs @@ -0,0 +1,1059 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The Items sub-client. + public partial class Items + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Items for mocking. + protected Items() + { + } + + /// Initializes a new instance of Items. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal Items(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Creates or updates a Item resource. + /// Id of the Catalog. + /// Unique resource ID. + /// Schema for records under the dataset. + /// Links for referencing other objects. + /// Status of the resource. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// OwnerItemId. + /// Assets. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> CreateAsync(string catalogId, string collectionId, IReadOnlyDictionary data, IEnumerable links = null, string status = null, string source = null, string name = null, string description = null, IReadOnlyDictionary properties = null, string ownerItemId = null, IEnumerable assets = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(data, nameof(data)); + + CreateRequest createRequest = new CreateRequest( + links?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + status, + source, + name, + description, + properties ?? new ChangeTrackingDictionary(), + data, + ownerItemId, + assets?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateAsync(catalogId, collectionId, createRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(ItemResponse.FromResponse(response), response); + } + + /// Creates or updates a Item resource. + /// Id of the Catalog. + /// Unique resource ID. + /// Schema for records under the dataset. + /// Links for referencing other objects. + /// Status of the resource. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// OwnerItemId. + /// Assets. + /// The cancellation token to use. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response Create(string catalogId, string collectionId, IReadOnlyDictionary data, IEnumerable links = null, string status = null, string source = null, string name = null, string description = null, IReadOnlyDictionary properties = null, string ownerItemId = null, IEnumerable assets = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(data, nameof(data)); + + CreateRequest createRequest = new CreateRequest( + links?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + status, + source, + name, + description, + properties ?? new ChangeTrackingDictionary(), + data, + ownerItemId, + assets?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = Create(catalogId, collectionId, createRequest.ToRequestContent(), context); + return Response.FromValue(ItemResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates or updates a Item resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateAsync(string catalogId, string collectionId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(catalogId, collectionId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Item resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Create(string catalogId, string collectionId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.Create"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateRequest(catalogId, collectionId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets a specified Item resource. + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetItemAsync(string catalogId, string collectionId, string itemId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetItemAsync(catalogId, collectionId, itemId, context).ConfigureAwait(false); + return Response.FromValue(Item.FromResponse(response), response); + } + + /// Gets a specified Item resource. + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The cancellation token to use. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetItem(string catalogId, string collectionId, string itemId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetItem(catalogId, collectionId, itemId, context); + return Response.FromValue(Item.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a specified Item resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetItemAsync(string catalogId, string collectionId, string itemId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + + using var scope = ClientDiagnostics.CreateScope("Items.GetItem"); + scope.Start(); + try + { + using HttpMessage message = CreateGetItemRequest(catalogId, collectionId, itemId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a specified Item resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetItem(string catalogId, string collectionId, string itemId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + + using var scope = ClientDiagnostics.CreateScope("Items.GetItem"); + scope.Start(); + try + { + using HttpMessage message = CreateGetItemRequest(catalogId, collectionId, itemId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Item resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAsync(string catalogId, string collectionId, string itemId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(catalogId, collectionId, itemId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Item resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdate(string catalogId, string collectionId, string itemId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(catalogId, collectionId, itemId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Item for given Item id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteAsync(string catalogId, string collectionId, string itemId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + + using var scope = ClientDiagnostics.CreateScope("Items.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(catalogId, collectionId, itemId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Item for given Item id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// Id of the Item. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// , or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Delete(string catalogId, string collectionId, string itemId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNullOrEmpty(itemId, nameof(itemId)); + + using var scope = ClientDiagnostics.CreateScope("Items.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(catalogId, collectionId, itemId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Search for Items across all parties by intersecting geometry. + /// Id of the Catalog. + /// Unique resource ID. + /// Owner Item Ids of the resource. + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetAllUnderCollectionAsync(string catalogId, string collectionId, IEnumerable ownerItemIds = null, IEnumerable dataFilters = null, GeoJsonObject intersectsWithGeometry = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, int? maximumPageSize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + GetAllUnderCollectionRequest getAllUnderCollectionRequest = new GetAllUnderCollectionRequest( + ownerItemIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + dataFilters?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + intersectsWithGeometry, + ids?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + minCreatedDateTime, + maxCreatedDateTime, + minLastModifiedDateTime, + maxLastModifiedDateTime, + maxPageSize, + skipToken, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetAllUnderCollectionAsync(catalogId, collectionId, getAllUnderCollectionRequest.ToRequestContent(), maximumPageSize, context).ConfigureAwait(false); + return Response.FromValue(ItemListResponse.FromResponse(response), response); + } + + /// Search for Items across all parties by intersecting geometry. + /// Id of the Catalog. + /// Unique resource ID. + /// Owner Item Ids of the resource. + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The cancellation token to use. + /// or is null. + /// or is an empty string, and was expected to be non-empty. + /// + public virtual Response GetAllUnderCollection(string catalogId, string collectionId, IEnumerable ownerItemIds = null, IEnumerable dataFilters = null, GeoJsonObject intersectsWithGeometry = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, int? maximumPageSize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + + GetAllUnderCollectionRequest getAllUnderCollectionRequest = new GetAllUnderCollectionRequest( + ownerItemIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + dataFilters?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + intersectsWithGeometry, + ids?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + minCreatedDateTime, + maxCreatedDateTime, + minLastModifiedDateTime, + maxLastModifiedDateTime, + maxPageSize, + skipToken, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetAllUnderCollection(catalogId, collectionId, getAllUnderCollectionRequest.ToRequestContent(), maximumPageSize, context); + return Response.FromValue(ItemListResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Search for Items across all parties by intersecting geometry. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetAllUnderCollectionAsync(string catalogId, string collectionId, RequestContent content, int? maximumPageSize = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.GetAllUnderCollection"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAllUnderCollectionRequest(catalogId, collectionId, content, maximumPageSize, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Search for Items across all parties by intersecting geometry. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// Unique resource ID. + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// , or is null. + /// or is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetAllUnderCollection(string catalogId, string collectionId, RequestContent content, int? maximumPageSize = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNullOrEmpty(collectionId, nameof(collectionId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.GetAllUnderCollection"); + scope.Start(); + try + { + using HttpMessage message = CreateGetAllUnderCollectionRequest(catalogId, collectionId, content, maximumPageSize, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Search for Items across all collections. + /// Id of the Catalog. + /// Owner Item Ids of the resource. + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// Owner Item Ids of the resource. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> SearchAcrossCollectionAsync(string catalogId, IEnumerable ownerItemIds = null, IEnumerable dataFilters = null, GeoJsonObject intersectsWithGeometry = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, IEnumerable collectionIds = null, int? maximumPageSize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + SearchAcrossCollectionRequest searchAcrossCollectionRequest = new SearchAcrossCollectionRequest( + ownerItemIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + dataFilters?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + intersectsWithGeometry, + ids?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + minCreatedDateTime, + maxCreatedDateTime, + minLastModifiedDateTime, + maxLastModifiedDateTime, + maxPageSize, + skipToken, + collectionIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await SearchAcrossCollectionAsync(catalogId, searchAcrossCollectionRequest.ToRequestContent(), maximumPageSize, context).ConfigureAwait(false); + return Response.FromValue(ItemListResponse.FromResponse(response), response); + } + + /// Search for Items across all collections. + /// Id of the Catalog. + /// Owner Item Ids of the resource. + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// Owner Item Ids of the resource. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response SearchAcrossCollection(string catalogId, IEnumerable ownerItemIds = null, IEnumerable dataFilters = null, GeoJsonObject intersectsWithGeometry = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, IEnumerable collectionIds = null, int? maximumPageSize = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + + SearchAcrossCollectionRequest searchAcrossCollectionRequest = new SearchAcrossCollectionRequest( + ownerItemIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + dataFilters?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + intersectsWithGeometry, + ids?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + minCreatedDateTime, + maxCreatedDateTime, + minLastModifiedDateTime, + maxLastModifiedDateTime, + maxPageSize, + skipToken, + collectionIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = SearchAcrossCollection(catalogId, searchAcrossCollectionRequest.ToRequestContent(), maximumPageSize, context); + return Response.FromValue(ItemListResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Search for Items across all collections. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task SearchAcrossCollectionAsync(string catalogId, RequestContent content, int? maximumPageSize = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.SearchAcrossCollection"); + scope.Start(); + try + { + using HttpMessage message = CreateSearchAcrossCollectionRequest(catalogId, content, maximumPageSize, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Search for Items across all collections. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Catalog. + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, + /// Default Value = 50. + /// + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response SearchAcrossCollection(string catalogId, RequestContent content, int? maximumPageSize = null, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(catalogId, nameof(catalogId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Items.SearchAcrossCollection"); + scope.Start(); + try + { + using HttpMessage message = CreateSearchAcrossCollectionRequest(catalogId, content, maximumPageSize, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCreateRequest(string catalogId, string collectionId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendPath("/items:create", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetItemRequest(string catalogId, string collectionId, string itemId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendPath("/items/", false); + uri.AppendPath(itemId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string catalogId, string collectionId, string itemId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendPath("/items/", false); + uri.AppendPath(itemId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(string catalogId, string collectionId, string itemId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendPath("/items/", false); + uri.AppendPath(itemId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetAllUnderCollectionRequest(string catalogId, string collectionId, RequestContent content, int? maximumPageSize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/collections/", false); + uri.AppendPath(collectionId, true); + uri.AppendPath("/items:search", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maximumPageSize != null) + { + uri.AppendQuery("maxPageSize", maximumPageSize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateSearchAcrossCollectionRequest(string catalogId, RequestContent content, int? maximumPageSize, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/catalogs/", false); + uri.AppendPath(catalogId, true); + uri.AppendPath("/items:search", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maximumPageSize != null) + { + uri.AppendQuery("maxPageSize", maximumPageSize.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/KeyVaultProperties.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/KeyVaultProperties.Serialization.cs new file mode 100644 index 000000000000..52aac10b2251 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/KeyVaultProperties.Serialization.cs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class KeyVaultProperties : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("keyVaultUri"u8); + writer.WriteStringValue(KeyVaultUri); + writer.WritePropertyName("keyName"u8); + writer.WriteStringValue(KeyName); + writer.WritePropertyName("keyVersion"u8); + writer.WriteStringValue(KeyVersion); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + KeyVaultProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeKeyVaultProperties(document.RootElement, options); + } + + internal static KeyVaultProperties DeserializeKeyVaultProperties(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string keyVaultUri = default; + string keyName = default; + string keyVersion = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("keyVaultUri"u8)) + { + keyVaultUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyName"u8)) + { + keyName = property.Value.GetString(); + continue; + } + if (property.NameEquals("keyVersion"u8)) + { + keyVersion = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new KeyVaultProperties(keyVaultUri, keyName, keyVersion, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support writing '{options.Format}' format."); + } + } + + KeyVaultProperties IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKeyVaultProperties(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(KeyVaultProperties)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static KeyVaultProperties FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeKeyVaultProperties(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/KeyVaultProperties.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/KeyVaultProperties.cs new file mode 100644 index 000000000000..353f35bcbf4d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/KeyVaultProperties.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Properties of the key vault. + public partial class KeyVaultProperties + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Uri of the key vault. + /// Name of Key Vault key. + /// Version of Key Vault key. + /// , or is null. + public KeyVaultProperties(string keyVaultUri, string keyName, string keyVersion) + { + Argument.AssertNotNull(keyVaultUri, nameof(keyVaultUri)); + Argument.AssertNotNull(keyName, nameof(keyName)); + Argument.AssertNotNull(keyVersion, nameof(keyVersion)); + + KeyVaultUri = keyVaultUri; + KeyName = keyName; + KeyVersion = keyVersion; + } + + /// Initializes a new instance of . + /// Uri of the key vault. + /// Name of Key Vault key. + /// Version of Key Vault key. + /// Keeps track of any properties unknown to the library. + internal KeyVaultProperties(string keyVaultUri, string keyName, string keyVersion, IDictionary serializedAdditionalRawData) + { + KeyVaultUri = keyVaultUri; + KeyName = keyName; + KeyVersion = keyVersion; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal KeyVaultProperties() + { + } + + /// Uri of the key vault. + public string KeyVaultUri { get; } + /// Name of Key Vault key. + public string KeyName { get; } + /// Version of Key Vault key. + public string KeyVersion { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Link.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Link.Serialization.cs new file mode 100644 index 000000000000..299db8f51d88 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Link.Serialization.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Link : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Link)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Rel)) + { + writer.WritePropertyName("rel"u8); + writer.WriteStringValue(Rel.Value.ToString()); + } + if (Optional.IsDefined(Href)) + { + writer.WritePropertyName("href"u8); + writer.WriteStringValue(Href); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type.Value.ToString()); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Link IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Link)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeLink(document.RootElement, options); + } + + internal static Link DeserializeLink(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + RelationshipType? rel = default; + string href = default; + DestinationType? type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("rel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + rel = new RelationshipType(property.Value.GetString()); + continue; + } + if (property.NameEquals("href"u8)) + { + href = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + type = new DestinationType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Link(rel, href, type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Link)} does not support writing '{options.Format}' format."); + } + } + + Link IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLink(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Link)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Link FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeLink(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Link.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Link.cs new file mode 100644 index 000000000000..27c5d4f754f7 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Link.cs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Link. + public partial class Link + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public Link() + { + } + + /// Initializes a new instance of . + /// Type of relationship. + /// Href. + /// DestinationType. + /// Keeps track of any properties unknown to the library. + internal Link(RelationshipType? rel, string href, DestinationType? type, IDictionary serializedAdditionalRawData) + { + Rel = rel; + Href = href; + Type = type; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Type of relationship. + public RelationshipType? Rel { get; set; } + /// Href. + public string Href { get; set; } + /// DestinationType. + public DestinationType? Type { get; set; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Measures.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Measures.Serialization.cs new file mode 100644 index 000000000000..ff7a6d861496 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Measures.Serialization.cs @@ -0,0 +1,170 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Measures : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Measures)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Unit)) + { + writer.WritePropertyName("unit"u8); + writer.WriteStringValue(Unit); + } + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Measures IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Measures)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMeasures(document.RootElement, options); + } + + internal static Measures DeserializeMeasures(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string unit = default; + IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Measures(unit, value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Measures)} does not support writing '{options.Format}' format."); + } + } + + Measures IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMeasures(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Measures)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Measures FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMeasures(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Measures.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Measures.cs new file mode 100644 index 000000000000..f1a84145e0e4 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Measures.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema for storing measurement readings and unit. + public partial class Measures + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal Measures() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Data unit. + /// Data values. + /// Keeps track of any properties unknown to the library. + internal Measures(string unit, IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + Unit = unit; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Data unit. + public string Unit { get; } + /// Data values. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/MultiPolygon.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/MultiPolygon.Serialization.cs new file mode 100644 index 000000000000..8bc5f76907e8 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/MultiPolygon.Serialization.cs @@ -0,0 +1,210 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class MultiPolygon : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MultiPolygon)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("coordinates"u8); + writer.WriteStartArray(); + foreach (var item in Coordinates) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item0 in item) + { + if (item0 == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item1 in item0) + { + if (item1 == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item2 in item1) + { + writer.WriteNumberValue(item2); + } + writer.WriteEndArray(); + } + writer.WriteEndArray(); + } + writer.WriteEndArray(); + } + writer.WriteEndArray(); + } + + MultiPolygon IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(MultiPolygon)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeMultiPolygon(document.RootElement, options); + } + + internal static MultiPolygon DeserializeMultiPolygon(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList>>> coordinates = default; + GeoJsonObjectType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("coordinates"u8)) + { + List>>> array = new List>>>(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + List>> array0 = new List>>(); + foreach (var item0 in item.EnumerateArray()) + { + if (item0.ValueKind == JsonValueKind.Null) + { + array0.Add(null); + } + else + { + List> array1 = new List>(); + foreach (var item1 in item0.EnumerateArray()) + { + if (item1.ValueKind == JsonValueKind.Null) + { + array1.Add(null); + } + else + { + List array2 = new List(); + foreach (var item2 in item1.EnumerateArray()) + { + array2.Add(item2.GetDouble()); + } + array1.Add(array2); + } + } + array0.Add(array1); + } + } + array.Add(array0); + } + } + coordinates = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = new GeoJsonObjectType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new MultiPolygon(type, serializedAdditionalRawData, coordinates); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(MultiPolygon)} does not support writing '{options.Format}' format."); + } + } + + MultiPolygon IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMultiPolygon(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(MultiPolygon)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new MultiPolygon FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeMultiPolygon(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/MultiPolygon.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/MultiPolygon.cs new file mode 100644 index 000000000000..70ab7302700c --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/MultiPolygon.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + /// MultiPolygon geometry. + public partial class MultiPolygon : GeoJsonObject + { + /// Initializes a new instance of . + /// + /// Gets or sets Coordinates of GeoJSON Object. + /// It must be an array of polygons, each polygon contains list of linear rings. + /// For Polygons with more than one of these rings, the first MUST be the exterior + /// ring, + /// and any others MUST be interior rings. + /// + /// is null. + public MultiPolygon(IEnumerable>>> coordinates) + { + Argument.AssertNotNull(coordinates, nameof(coordinates)); + + Type = GeoJsonObjectType.MultiPolygon; + Coordinates = coordinates.ToList(); + } + + /// Initializes a new instance of . + /// Type of GeoJSON object. + /// Keeps track of any properties unknown to the library. + /// + /// Gets or sets Coordinates of GeoJSON Object. + /// It must be an array of polygons, each polygon contains list of linear rings. + /// For Polygons with more than one of these rings, the first MUST be the exterior + /// ring, + /// and any others MUST be interior rings. + /// + internal MultiPolygon(GeoJsonObjectType type, IDictionary serializedAdditionalRawData, IList>>> coordinates) : base(type, serializedAdditionalRawData) + { + Coordinates = coordinates; + } + + /// Initializes a new instance of for deserialization. + internal MultiPolygon() + { + } + + /// + /// Gets or sets Coordinates of GeoJSON Object. + /// It must be an array of polygons, each polygon contains list of linear rings. + /// For Polygons with more than one of these rings, the first MUST be the exterior + /// ring, + /// and any others MUST be interior rings. + /// + public IList>>> Coordinates { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/OauthClientCredentials.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/OauthClientCredentials.Serialization.cs new file mode 100644 index 000000000000..fc0f99fd24df --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/OauthClientCredentials.Serialization.cs @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class OauthClientCredentials : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OauthClientCredentials)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("clientId"u8); + writer.WriteStringValue(ClientId); + writer.WritePropertyName("clientSecret"u8); + writer.WriteObjectValue(ClientSecret, options); + } + + OauthClientCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(OauthClientCredentials)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeOauthClientCredentials(document.RootElement, options); + } + + internal static OauthClientCredentials DeserializeOauthClientCredentials(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string clientId = default; + KeyVaultProperties clientSecret = default; + AuthCredentialsKind kind = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("clientId"u8)) + { + clientId = property.Value.GetString(); + continue; + } + if (property.NameEquals("clientSecret"u8)) + { + clientSecret = KeyVaultProperties.DeserializeKeyVaultProperties(property.Value, options); + continue; + } + if (property.NameEquals("kind"u8)) + { + kind = new AuthCredentialsKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new OauthClientCredentials(kind, serializedAdditionalRawData, clientId, clientSecret); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(OauthClientCredentials)} does not support writing '{options.Format}' format."); + } + } + + OauthClientCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOauthClientCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(OauthClientCredentials)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new OauthClientCredentials FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeOauthClientCredentials(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/OauthClientCredentials.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/OauthClientCredentials.cs new file mode 100644 index 000000000000..9250c62b5420 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/OauthClientCredentials.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// OAuthClientCredentials for clientId clientSecret auth. + public partial class OauthClientCredentials : AuthCredentials + { + /// Initializes a new instance of . + /// ClientId associated with the provider. + /// Properties of the key vault. + /// or is null. + public OauthClientCredentials(string clientId, KeyVaultProperties clientSecret) + { + Argument.AssertNotNull(clientId, nameof(clientId)); + Argument.AssertNotNull(clientSecret, nameof(clientSecret)); + + Kind = AuthCredentialsKind.OAuthClientCredentials; + ClientId = clientId; + ClientSecret = clientSecret; + } + + /// Initializes a new instance of . + /// Enum for different types of AuthCredentials supported. + /// Keeps track of any properties unknown to the library. + /// ClientId associated with the provider. + /// Properties of the key vault. + internal OauthClientCredentials(AuthCredentialsKind kind, IDictionary serializedAdditionalRawData, string clientId, KeyVaultProperties clientSecret) : base(kind, serializedAdditionalRawData) + { + ClientId = clientId; + ClientSecret = clientSecret; + } + + /// Initializes a new instance of for deserialization. + internal OauthClientCredentials() + { + } + + /// ClientId associated with the provider. + public string ClientId { get; } + /// Properties of the key vault. + public KeyVaultProperties ClientSecret { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Point.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Point.Serialization.cs new file mode 100644 index 000000000000..80c41f9eddb3 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Point.Serialization.cs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Point : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Point)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("coordinates"u8); + writer.WriteStartArray(); + foreach (var item in Coordinates) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + + Point IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Point)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePoint(document.RootElement, options); + } + + internal static Point DeserializePoint(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList coordinates = default; + GeoJsonObjectType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("coordinates"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + coordinates = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = new GeoJsonObjectType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Point(type, serializedAdditionalRawData, coordinates); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Point)} does not support writing '{options.Format}' format."); + } + } + + Point IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePoint(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Point)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new Point FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePoint(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Point.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Point.cs new file mode 100644 index 000000000000..7395a443f858 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Point.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + /// Point geometry. + public partial class Point : GeoJsonObject + { + /// Initializes a new instance of . + /// + /// Gets or sets the coordinate of this point. + /// It must be an array of 2 or 3 elements for a 2D or 3D system. + /// + /// is null. + public Point(IEnumerable coordinates) + { + Argument.AssertNotNull(coordinates, nameof(coordinates)); + + Type = GeoJsonObjectType.Point; + Coordinates = coordinates.ToList(); + } + + /// Initializes a new instance of . + /// Type of GeoJSON object. + /// Keeps track of any properties unknown to the library. + /// + /// Gets or sets the coordinate of this point. + /// It must be an array of 2 or 3 elements for a 2D or 3D system. + /// + internal Point(GeoJsonObjectType type, IDictionary serializedAdditionalRawData, IList coordinates) : base(type, serializedAdditionalRawData) + { + Coordinates = coordinates; + } + + /// Initializes a new instance of for deserialization. + internal Point() + { + } + + /// + /// Gets or sets the coordinate of this point. + /// It must be an array of 2 or 3 elements for a 2D or 3D system. + /// + public IList Coordinates { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Polygon.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Polygon.Serialization.cs new file mode 100644 index 000000000000..a7addc03c701 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Polygon.Serialization.cs @@ -0,0 +1,188 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Polygon : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Polygon)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + writer.WritePropertyName("coordinates"u8); + writer.WriteStartArray(); + foreach (var item in Coordinates) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item0 in item) + { + if (item0 == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStartArray(); + foreach (var item1 in item0) + { + writer.WriteNumberValue(item1); + } + writer.WriteEndArray(); + } + writer.WriteEndArray(); + } + writer.WriteEndArray(); + } + + Polygon IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Polygon)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializePolygon(document.RootElement, options); + } + + internal static Polygon DeserializePolygon(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList>> coordinates = default; + GeoJsonObjectType type = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("coordinates"u8)) + { + List>> array = new List>>(); + foreach (var item in property.Value.EnumerateArray()) + { + if (item.ValueKind == JsonValueKind.Null) + { + array.Add(null); + } + else + { + List> array0 = new List>(); + foreach (var item0 in item.EnumerateArray()) + { + if (item0.ValueKind == JsonValueKind.Null) + { + array0.Add(null); + } + else + { + List array1 = new List(); + foreach (var item1 in item0.EnumerateArray()) + { + array1.Add(item1.GetDouble()); + } + array0.Add(array1); + } + } + array.Add(array0); + } + } + coordinates = array; + continue; + } + if (property.NameEquals("type"u8)) + { + type = new GeoJsonObjectType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Polygon(type, serializedAdditionalRawData, coordinates); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Polygon)} does not support writing '{options.Format}' format."); + } + } + + Polygon IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePolygon(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Polygon)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new Polygon FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializePolygon(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Polygon.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Polygon.cs new file mode 100644 index 000000000000..755a3756d216 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Polygon.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + /// Polygon geometry. + public partial class Polygon : GeoJsonObject + { + /// Initializes a new instance of . + /// + /// Gets or sets type of the GeoJSON Object. + /// It must be an array of linear ring coordinate arrays. + /// For Polygons with more than one of these rings, the first MUST be the exterior + /// ring, + /// and any others MUST be interior rings. + /// + /// is null. + public Polygon(IEnumerable>> coordinates) + { + Argument.AssertNotNull(coordinates, nameof(coordinates)); + + Type = GeoJsonObjectType.Polygon; + Coordinates = coordinates.ToList(); + } + + /// Initializes a new instance of . + /// Type of GeoJSON object. + /// Keeps track of any properties unknown to the library. + /// + /// Gets or sets type of the GeoJSON Object. + /// It must be an array of linear ring coordinate arrays. + /// For Polygons with more than one of these rings, the first MUST be the exterior + /// ring, + /// and any others MUST be interior rings. + /// + internal Polygon(GeoJsonObjectType type, IDictionary serializedAdditionalRawData, IList>> coordinates) : base(type, serializedAdditionalRawData) + { + Coordinates = coordinates; + } + + /// Initializes a new instance of for deserialization. + internal Polygon() + { + } + + /// + /// Gets or sets type of the GeoJSON Object. + /// It must be an array of linear ring coordinate arrays. + /// For Polygons with more than one of these rings, the first MUST be the exterior + /// ring, + /// and any others MUST be interior rings. + /// + public IList>> Coordinates { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/RelationshipType.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/RelationshipType.cs new file mode 100644 index 000000000000..94ced156dcb1 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/RelationshipType.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ComponentModel; + +namespace Azure.AgriculturePlatform +{ + /// Type of relationship. + public readonly partial struct RelationshipType : IEquatable + { + private readonly string _value; + + /// Initializes a new instance of . + /// is null. + public RelationshipType(string value) + { + _value = value ?? throw new ArgumentNullException(nameof(value)); + } + + private const string DerivedFromValue = "DerivedFrom"; + private const string ChildValue = "Child"; + private const string ParentValue = "Parent"; + + /// DerivedFrom. + public static RelationshipType DerivedFrom { get; } = new RelationshipType(DerivedFromValue); + /// Contains. + public static RelationshipType Child { get; } = new RelationshipType(ChildValue); + /// Parent. + public static RelationshipType Parent { get; } = new RelationshipType(ParentValue); + /// Determines if two values are the same. + public static bool operator ==(RelationshipType left, RelationshipType right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(RelationshipType left, RelationshipType right) => !left.Equals(right); + /// Converts a to a . + public static implicit operator RelationshipType(string value) => new RelationshipType(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is RelationshipType other && Equals(other); + /// + public bool Equals(RelationshipType other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value != null ? StringComparer.InvariantCultureIgnoreCase.GetHashCode(_value) : 0; + /// + public override string ToString() => _value; + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerRequestBody.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerRequestBody.Serialization.cs new file mode 100644 index 000000000000..d07ab8947407 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerRequestBody.Serialization.cs @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class SamplePartnerRequestBody : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SamplePartnerRequestBody)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(SolutionId)) + { + writer.WritePropertyName("solutionId"u8); + writer.WriteStringValue(SolutionId); + } + if (Optional.IsDefined(PartyId)) + { + writer.WritePropertyName("partyId"u8); + writer.WriteStringValue(PartyId); + } + if (Optional.IsDefined(GddStartDate)) + { + writer.WritePropertyName("gddStartDate"u8); + writer.WriteStringValue(GddStartDate.Value, "O"); + } + if (Optional.IsDefined(GddEndDate)) + { + writer.WritePropertyName("gddEndDate"u8); + writer.WriteStringValue(GddEndDate.Value, "O"); + } + if (Optional.IsDefined(ResourceId)) + { + writer.WritePropertyName("resourceId"u8); + writer.WriteStringValue(ResourceId); + } + if (Optional.IsDefined(ResourceType)) + { + writer.WritePropertyName("resourceType"u8); + writer.WriteStringValue(ResourceType); + } + if (Optional.IsDefined(Crop)) + { + writer.WritePropertyName("crop"u8); + writer.WriteStringValue(Crop); + } + if (Optional.IsDefined(TemperatureUnit)) + { + writer.WritePropertyName("temperatureUnit"u8); + writer.WriteStringValue(TemperatureUnit); + } + if (Optional.IsDefined(Method)) + { + writer.WritePropertyName("method"u8); + writer.WriteStringValue(Method); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SamplePartnerRequestBody IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SamplePartnerRequestBody)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSamplePartnerRequestBody(document.RootElement, options); + } + + internal static SamplePartnerRequestBody DeserializeSamplePartnerRequestBody(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string solutionId = default; + string partyId = default; + DateTimeOffset? gddStartDate = default; + DateTimeOffset? gddEndDate = default; + string resourceId = default; + string resourceType = default; + string crop = default; + string temperatureUnit = default; + string method = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("solutionId"u8)) + { + solutionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("partyId"u8)) + { + partyId = property.Value.GetString(); + continue; + } + if (property.NameEquals("gddStartDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + gddStartDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("gddEndDate"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + gddEndDate = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("resourceId"u8)) + { + resourceId = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceType"u8)) + { + resourceType = property.Value.GetString(); + continue; + } + if (property.NameEquals("crop"u8)) + { + crop = property.Value.GetString(); + continue; + } + if (property.NameEquals("temperatureUnit"u8)) + { + temperatureUnit = property.Value.GetString(); + continue; + } + if (property.NameEquals("method"u8)) + { + method = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SamplePartnerRequestBody( + solutionId, + partyId, + gddStartDate, + gddEndDate, + resourceId, + resourceType, + crop, + temperatureUnit, + method, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SamplePartnerRequestBody)} does not support writing '{options.Format}' format."); + } + } + + SamplePartnerRequestBody IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSamplePartnerRequestBody(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SamplePartnerRequestBody)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SamplePartnerRequestBody FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSamplePartnerRequestBody(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerRequestBody.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerRequestBody.cs new file mode 100644 index 000000000000..b5b8a8834842 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerRequestBody.cs @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// SamplePartnerRequestBody. + public partial class SamplePartnerRequestBody + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal SamplePartnerRequestBody() + { + } + + /// Initializes a new instance of . + /// SolutionId. + /// PartyId. + /// GddStartDate. + /// GddEndDate. + /// ResourceId. + /// ResourceType. + /// Crop. + /// TemperatureUnit. + /// Method. + /// Keeps track of any properties unknown to the library. + internal SamplePartnerRequestBody(string solutionId, string partyId, DateTimeOffset? gddStartDate, DateTimeOffset? gddEndDate, string resourceId, string resourceType, string crop, string temperatureUnit, string method, IDictionary serializedAdditionalRawData) + { + SolutionId = solutionId; + PartyId = partyId; + GddStartDate = gddStartDate; + GddEndDate = gddEndDate; + ResourceId = resourceId; + ResourceType = resourceType; + Crop = crop; + TemperatureUnit = temperatureUnit; + Method = method; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// SolutionId. + public string SolutionId { get; } + /// PartyId. + public string PartyId { get; } + /// GddStartDate. + public DateTimeOffset? GddStartDate { get; } + /// GddEndDate. + public DateTimeOffset? GddEndDate { get; } + /// ResourceId. + public string ResourceId { get; } + /// ResourceType. + public string ResourceType { get; } + /// Crop. + public string Crop { get; } + /// TemperatureUnit. + public string TemperatureUnit { get; } + /// Method. + public string Method { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerResponse.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerResponse.Serialization.cs new file mode 100644 index 000000000000..fb86dfffb3a2 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerResponse.Serialization.cs @@ -0,0 +1,231 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class SamplePartnerResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SamplePartnerResponse)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (Optional.IsDefined(Message)) + { + writer.WritePropertyName("message"u8); + writer.WriteStringValue(Message); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (Optional.IsDefined(JobCreatedDateTime)) + { + writer.WritePropertyName("jobCreatedDateTime"u8); + writer.WriteStringValue(JobCreatedDateTime.Value, "O"); + } + if (Optional.IsDefined(JobLastActionDateTime)) + { + writer.WritePropertyName("jobLastActionDateTime"u8); + writer.WriteStringValue(JobLastActionDateTime.Value, "O"); + } + if (Optional.IsDefined(E2Eid)) + { + writer.WritePropertyName("e2eid"u8); + writer.WriteStringValue(E2Eid); + } + if (Optional.IsDefined(PartnerRequestBody)) + { + writer.WritePropertyName("partnerRequestBody"u8); + writer.WriteObjectValue(PartnerRequestBody, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SamplePartnerResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SamplePartnerResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSamplePartnerResponse(document.RootElement, options); + } + + internal static SamplePartnerResponse DeserializeSamplePartnerResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + string message = default; + string status = default; + DateTimeOffset? jobCreatedDateTime = default; + DateTimeOffset? jobLastActionDateTime = default; + string e2eid = default; + SamplePartnerRequestBody partnerRequestBody = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("jobCreatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + jobCreatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("jobLastActionDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + jobLastActionDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("e2eid"u8)) + { + e2eid = property.Value.GetString(); + continue; + } + if (property.NameEquals("partnerRequestBody"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + partnerRequestBody = SamplePartnerRequestBody.DeserializeSamplePartnerRequestBody(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SamplePartnerResponse( + id, + message, + status, + jobCreatedDateTime, + jobLastActionDateTime, + e2eid, + partnerRequestBody, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SamplePartnerResponse)} does not support writing '{options.Format}' format."); + } + } + + SamplePartnerResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSamplePartnerResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SamplePartnerResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SamplePartnerResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSamplePartnerResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerResponse.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerResponse.cs new file mode 100644 index 000000000000..9e03da63f3a2 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SamplePartnerResponse.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// SamplePartnerResponse. + public partial class SamplePartnerResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal SamplePartnerResponse() + { + } + + /// Initializes a new instance of . + /// Id. + /// Message. + /// Status. + /// JobCreatedDateTime. + /// JobLastActionDateTime. + /// E2eid. + /// SamplePartnerRequestBody. + /// Keeps track of any properties unknown to the library. + internal SamplePartnerResponse(string id, string message, string status, DateTimeOffset? jobCreatedDateTime, DateTimeOffset? jobLastActionDateTime, string e2Eid, SamplePartnerRequestBody partnerRequestBody, IDictionary serializedAdditionalRawData) + { + Id = id; + Message = message; + Status = status; + JobCreatedDateTime = jobCreatedDateTime; + JobLastActionDateTime = jobLastActionDateTime; + E2Eid = e2Eid; + PartnerRequestBody = partnerRequestBody; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Id. + public string Id { get; } + /// Message. + public string Message { get; } + /// Status. + public string Status { get; } + /// JobCreatedDateTime. + public DateTimeOffset? JobCreatedDateTime { get; } + /// JobLastActionDateTime. + public DateTimeOffset? JobLastActionDateTime { get; } + /// E2eid. + public string E2Eid { get; } + /// SamplePartnerRequestBody. + public SamplePartnerRequestBody PartnerRequestBody { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Satellite.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Satellite.cs new file mode 100644 index 000000000000..7233d2e95a65 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Satellite.cs @@ -0,0 +1,470 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The Satellite sub-client. + public partial class Satellite + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Satellite for mocking. + protected Satellite() + { + } + + /// Initializes a new instance of Satellite. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal Satellite(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Fetches Satellite data. + /// OAuthClientCredentials for clientId clientSecret auth. + /// Provider of satellite data. Available Value: SentinelHub. + /// ItemUri. + /// Data Model for SatelliteIngestionJobRequest. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Start Date. + /// End Date. + /// Feature Id. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// , , , or is null. + /// + public virtual async Task> FetchItemsAsync(OauthClientCredentials credentials, string provider, string itemUri, SatelliteData data, string providerCollectionId, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, string featureId = null, int? maxpagesize = null, int? skip = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(credentials, nameof(credentials)); + Argument.AssertNotNull(provider, nameof(provider)); + Argument.AssertNotNull(itemUri, nameof(itemUri)); + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(providerCollectionId, nameof(providerCollectionId)); + + FetchItemsRequest fetchItemsRequest = new FetchItemsRequest( + startDateTime, + credentials, + endDateTime, + provider, + itemUri, + data, + providerCollectionId, + featureId, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await FetchItemsAsync(fetchItemsRequest.ToRequestContent(), maxpagesize, skip, context).ConfigureAwait(false); + return Response.FromValue(SatelliteFetchResponse.FromResponse(response), response); + } + + /// Fetches Satellite data. + /// OAuthClientCredentials for clientId clientSecret auth. + /// Provider of satellite data. Available Value: SentinelHub. + /// ItemUri. + /// Data Model for SatelliteIngestionJobRequest. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Start Date. + /// End Date. + /// Feature Id. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// , , , or is null. + /// + public virtual Response FetchItems(OauthClientCredentials credentials, string provider, string itemUri, SatelliteData data, string providerCollectionId, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, string featureId = null, int? maxpagesize = null, int? skip = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(credentials, nameof(credentials)); + Argument.AssertNotNull(provider, nameof(provider)); + Argument.AssertNotNull(itemUri, nameof(itemUri)); + Argument.AssertNotNull(data, nameof(data)); + Argument.AssertNotNull(providerCollectionId, nameof(providerCollectionId)); + + FetchItemsRequest fetchItemsRequest = new FetchItemsRequest( + startDateTime, + credentials, + endDateTime, + provider, + itemUri, + data, + providerCollectionId, + featureId, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = FetchItems(fetchItemsRequest.ToRequestContent(), maxpagesize, skip, context); + return Response.FromValue(SatelliteFetchResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Fetches Satellite data. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task FetchItemsAsync(RequestContent content, int? maxpagesize = null, int? skip = null, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Satellite.FetchItems"); + scope.Start(); + try + { + using HttpMessage message = CreateFetchItemsRequest(content, maxpagesize, skip, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Fetches Satellite data. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response FetchItems(RequestContent content, int? maxpagesize = null, int? skip = null, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Satellite.FetchItems"); + scope.Start(); + try + { + using HttpMessage message = CreateFetchItemsRequest(content, maxpagesize, skip, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// Searches for STAC items by collection id, bbox, intersecting geometry, start + /// and end datetime. + /// + /// OAuthClientCredentials for clientId clientSecret auth. + /// Provider of satellite data. Available Value: SentinelHub. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Start datetime of the time interval in which to search for Items. + /// End datetime of the time interval in which to search for Items. + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// + /// + /// Only items that have a geometry that intersects the bounding box are selected. + /// The bounding box is provided as four numbers. The coordinate reference system + /// of the values is WGS84 longitude/latitude. + /// + /// Array of feature ids to return. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// , or is null. + /// + public virtual async Task> SearchItemsAsync(OauthClientCredentials credentials, string provider, string providerCollectionId, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, GeoJsonObject intersects = null, IEnumerable bbox = null, IEnumerable featureIds = null, int? maxpagesize = null, int? skip = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(credentials, nameof(credentials)); + Argument.AssertNotNull(provider, nameof(provider)); + Argument.AssertNotNull(providerCollectionId, nameof(providerCollectionId)); + + SearchItemsRequest searchItemsRequest = new SearchItemsRequest( + startDateTime, + credentials, + provider, + endDateTime, + intersects, + bbox?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + featureIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + providerCollectionId, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await SearchItemsAsync(searchItemsRequest.ToRequestContent(), maxpagesize, skip, context).ConfigureAwait(false); + return Response.FromValue(SearchFeaturesResponse.FromResponse(response), response); + } + + /// + /// Searches for STAC items by collection id, bbox, intersecting geometry, start + /// and end datetime. + /// + /// OAuthClientCredentials for clientId clientSecret auth. + /// Provider of satellite data. Available Value: SentinelHub. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Start datetime of the time interval in which to search for Items. + /// End datetime of the time interval in which to search for Items. + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// + /// + /// Only items that have a geometry that intersects the bounding box are selected. + /// The bounding box is provided as four numbers. The coordinate reference system + /// of the values is WGS84 longitude/latitude. + /// + /// Array of feature ids to return. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// , or is null. + /// + public virtual Response SearchItems(OauthClientCredentials credentials, string provider, string providerCollectionId, DateTimeOffset? startDateTime = null, DateTimeOffset? endDateTime = null, GeoJsonObject intersects = null, IEnumerable bbox = null, IEnumerable featureIds = null, int? maxpagesize = null, int? skip = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(credentials, nameof(credentials)); + Argument.AssertNotNull(provider, nameof(provider)); + Argument.AssertNotNull(providerCollectionId, nameof(providerCollectionId)); + + SearchItemsRequest searchItemsRequest = new SearchItemsRequest( + startDateTime, + credentials, + provider, + endDateTime, + intersects, + bbox?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + featureIds?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + providerCollectionId, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = SearchItems(searchItemsRequest.ToRequestContent(), maxpagesize, skip, context); + return Response.FromValue(SearchFeaturesResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Searches for STAC items by collection id, bbox, intersecting geometry, start + /// and end datetime. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task SearchItemsAsync(RequestContent content, int? maxpagesize = null, int? skip = null, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Satellite.SearchItems"); + scope.Start(); + try + { + using HttpMessage message = CreateSearchItemsRequest(content, maxpagesize, skip, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Searches for STAC items by collection id, bbox, intersecting geometry, start + /// and end datetime. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// + /// Maximum number of items needed (inclusive). Minimum = 1, Maximum = 100, Default + /// value = 10. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response SearchItems(RequestContent content, int? maxpagesize = null, int? skip = null, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Satellite.SearchItems"); + scope.Start(); + try + { + using HttpMessage message = CreateSearchItemsRequest(content, maxpagesize, skip, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateFetchItemsRequest(RequestContent content, int? maxpagesize, int? skip, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/external/satellite:fetch", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateSearchItemsRequest(RequestContent content, int? maxpagesize, int? skip, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/external/satellite:stac", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (maxpagesize != null) + { + uri.AppendQuery("maxpagesize", maxpagesize.Value, true); + } + if (skip != null) + { + uri.AppendQuery("skip", skip.Value, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteData.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteData.Serialization.cs new file mode 100644 index 000000000000..8dd13d2bb40a --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteData.Serialization.cs @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class SatelliteData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SatelliteData)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(ImageNames)) + { + writer.WritePropertyName("imageNames"u8); + writer.WriteStartArray(); + foreach (var item in ImageNames) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ImageFormats)) + { + writer.WritePropertyName("imageFormats"u8); + writer.WriteStartArray(); + foreach (var item in ImageFormats) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ImageResolutions)) + { + writer.WritePropertyName("imageResolutions"u8); + writer.WriteStartArray(); + foreach (var item in ImageResolutions) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SatelliteData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SatelliteData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSatelliteData(document.RootElement, options); + } + + internal static SatelliteData DeserializeSatelliteData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList imageNames = default; + IList imageFormats = default; + IList imageResolutions = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("imageNames"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + imageNames = array; + continue; + } + if (property.NameEquals("imageFormats"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + imageFormats = array; + continue; + } + if (property.NameEquals("imageResolutions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + imageResolutions = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SatelliteData(imageNames ?? new ChangeTrackingList(), imageFormats ?? new ChangeTrackingList(), imageResolutions ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SatelliteData)} does not support writing '{options.Format}' format."); + } + } + + SatelliteData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSatelliteData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SatelliteData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SatelliteData FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSatelliteData(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteData.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteData.cs new file mode 100644 index 000000000000..a7dc9301da8e --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteData.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Data Model for SatelliteIngestionJobRequest. + public partial class SatelliteData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + public SatelliteData() + { + ImageNames = new ChangeTrackingList(); + ImageFormats = new ChangeTrackingList(); + ImageResolutions = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of ImageNames. + /// List of ImageFormats. Available value: TIF. + /// List of ImageResolutions in meters. Available values: 10, 20, 60. + /// Keeps track of any properties unknown to the library. + internal SatelliteData(IList imageNames, IList imageFormats, IList imageResolutions, IDictionary serializedAdditionalRawData) + { + ImageNames = imageNames; + ImageFormats = imageFormats; + ImageResolutions = imageResolutions; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of ImageNames. + public IList ImageNames { get; } + /// List of ImageFormats. Available value: TIF. + public IList ImageFormats { get; } + /// List of ImageResolutions in meters. Available values: 10, 20, 60. + public IList ImageResolutions { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchData.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchData.Serialization.cs new file mode 100644 index 000000000000..01d78076d2e7 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchData.Serialization.cs @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class SatelliteFetchData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SatelliteFetchData)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(DateTime)) + { + writer.WritePropertyName("dateTime"u8); + writer.WriteStringValue(DateTime.Value, "O"); + } + if (Optional.IsDefined(Provider)) + { + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + } + writer.WritePropertyName("providerCollectionId"u8); + writer.WriteStringValue(ProviderCollectionId); + if (Optional.IsDefined(FeatureId)) + { + writer.WritePropertyName("featureId"u8); + writer.WriteStringValue(FeatureId); + } + if (Optional.IsCollectionDefined(ImageFiles)) + { + writer.WritePropertyName("imageFiles"u8); + writer.WriteStartArray(); + foreach (var item in ImageFiles) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(ItemUri)) + { + writer.WritePropertyName("itemUri"u8); + writer.WriteStringValue(ItemUri); + } + if (Optional.IsDefined(Id)) + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SatelliteFetchData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SatelliteFetchData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSatelliteFetchData(document.RootElement, options); + } + + internal static SatelliteFetchData DeserializeSatelliteFetchData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset? dateTime = default; + string provider = default; + string providerCollectionId = default; + string featureId = default; + IReadOnlyList imageFiles = default; + string itemUri = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("dateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + dateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("providerCollectionId"u8)) + { + providerCollectionId = property.Value.GetString(); + continue; + } + if (property.NameEquals("featureId"u8)) + { + featureId = property.Value.GetString(); + continue; + } + if (property.NameEquals("imageFiles"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ImageFile.DeserializeImageFile(item, options)); + } + imageFiles = array; + continue; + } + if (property.NameEquals("itemUri"u8)) + { + itemUri = property.Value.GetString(); + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SatelliteFetchData( + dateTime, + provider, + providerCollectionId, + featureId, + imageFiles ?? new ChangeTrackingList(), + itemUri, + id, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SatelliteFetchData)} does not support writing '{options.Format}' format."); + } + } + + SatelliteFetchData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSatelliteFetchData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SatelliteFetchData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SatelliteFetchData FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSatelliteFetchData(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchData.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchData.cs new file mode 100644 index 000000000000..f63e5440c19e --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchData.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// SatelliteFetchData. + public partial class SatelliteFetchData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// is null. + internal SatelliteFetchData(string providerCollectionId) + { + Argument.AssertNotNull(providerCollectionId, nameof(providerCollectionId)); + + ProviderCollectionId = providerCollectionId; + ImageFiles = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Start Date. + /// Provider of satellite data. Available Value: SentinelHub. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Feature Id. + /// ImageFiles. + /// ItemUri. + /// Id. + /// Keeps track of any properties unknown to the library. + internal SatelliteFetchData(DateTimeOffset? dateTime, string provider, string providerCollectionId, string featureId, IReadOnlyList imageFiles, string itemUri, string id, IDictionary serializedAdditionalRawData) + { + DateTime = dateTime; + Provider = provider; + ProviderCollectionId = providerCollectionId; + FeatureId = featureId; + ImageFiles = imageFiles; + ItemUri = itemUri; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SatelliteFetchData() + { + } + + /// Start Date. + public DateTimeOffset? DateTime { get; } + /// Provider of satellite data. Available Value: SentinelHub. + public string Provider { get; } + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + public string ProviderCollectionId { get; } + /// Feature Id. + public string FeatureId { get; } + /// ImageFiles. + public IReadOnlyList ImageFiles { get; } + /// ItemUri. + public string ItemUri { get; } + /// Id. + public string Id { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchResponse.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchResponse.Serialization.cs new file mode 100644 index 000000000000..680b8bbc42e2 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchResponse.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class SatelliteFetchResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SatelliteFetchResponse)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Value)) + { + writer.WritePropertyName("value"u8); + writer.WriteStartArray(); + foreach (var item in Value) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SatelliteFetchResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SatelliteFetchResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSatelliteFetchResponse(document.RootElement, options); + } + + internal static SatelliteFetchResponse DeserializeSatelliteFetchResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(SatelliteFetchData.DeserializeSatelliteFetchData(item, options)); + } + value = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SatelliteFetchResponse(value ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SatelliteFetchResponse)} does not support writing '{options.Format}' format."); + } + } + + SatelliteFetchResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSatelliteFetchResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SatelliteFetchResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SatelliteFetchResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSatelliteFetchResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchResponse.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchResponse.cs new file mode 100644 index 000000000000..fc4903bc31b9 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SatelliteFetchResponse.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Satellite Fetch Response. + public partial class SatelliteFetchResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal SatelliteFetchResponse() + { + Value = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Value. + /// Keeps track of any properties unknown to the library. + internal SatelliteFetchResponse(IReadOnlyList value, IDictionary serializedAdditionalRawData) + { + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Value. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schema.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schema.Serialization.cs new file mode 100644 index 000000000000..4f4cddf09375 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schema.Serialization.cs @@ -0,0 +1,400 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class Schema : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Schema)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Links)) + { + writer.WritePropertyName("links"u8); + writer.WriteStartArray(); + foreach (var item in Links) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && Optional.IsDefined(ETag)) + { + writer.WritePropertyName("eTag"u8); + writer.WriteStringValue(ETag); + } + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (options.Format != "W" && Optional.IsDefined(CreatedDateTime)) + { + writer.WritePropertyName("createdDateTime"u8); + writer.WriteStringValue(CreatedDateTime.Value, "O"); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedDateTime)) + { + writer.WritePropertyName("modifiedDateTime"u8); + writer.WriteStringValue(ModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(Source)) + { + writer.WritePropertyName("source"u8); + writer.WriteStringValue(Source); + } + if (Optional.IsDefined(Name)) + { + writer.WritePropertyName("name"u8); + writer.WriteStringValue(Name); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (options.Format != "W" && Optional.IsDefined(CreatedBy)) + { + writer.WritePropertyName("createdBy"u8); + writer.WriteStringValue(CreatedBy); + } + if (options.Format != "W" && Optional.IsDefined(ModifiedBy)) + { + writer.WritePropertyName("modifiedBy"u8); + writer.WriteStringValue(ModifiedBy); + } + if (Optional.IsCollectionDefined(Properties)) + { + writer.WritePropertyName("properties"u8); + writer.WriteStartObject(); + foreach (var item in Properties) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + if (options.Format != "W" && Optional.IsCollectionDefined(DependentCollections)) + { + writer.WritePropertyName("dependentCollections"u8); + writer.WriteStartArray(); + foreach (var item in DependentCollections) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("schemaModel"u8); + writer.WriteStartObject(); + foreach (var item in SchemaModel) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + if (options.Format != "W") + { + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + Schema IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(Schema)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSchema(document.RootElement, options); + } + + internal static Schema DeserializeSchema(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IList links = default; + string eTag = default; + string status = default; + DateTimeOffset? createdDateTime = default; + DateTimeOffset? modifiedDateTime = default; + string source = default; + string name = default; + string description = default; + string createdBy = default; + string modifiedBy = default; + IDictionary properties = default; + IReadOnlyList dependentCollections = default; + IDictionary schemaModel = default; + string id = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("links"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(Link.DeserializeLink(item, options)); + } + links = array; + continue; + } + if (property.NameEquals("eTag"u8)) + { + eTag = property.Value.GetString(); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + createdDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("modifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + modifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("source"u8)) + { + source = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("createdBy"u8)) + { + createdBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("modifiedBy"u8)) + { + modifiedBy = property.Value.GetString(); + continue; + } + if (property.NameEquals("properties"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + properties = dictionary; + continue; + } + if (property.NameEquals("dependentCollections"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(CatalogCollection.DeserializeCatalogCollection(item, options)); + } + dependentCollections = array; + continue; + } + if (property.NameEquals("schemaModel"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + schemaModel = dictionary; + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new Schema( + links ?? new ChangeTrackingList(), + eTag, + status, + createdDateTime, + modifiedDateTime, + source, + name, + description, + createdBy, + modifiedBy, + properties ?? new ChangeTrackingDictionary(), + dependentCollections ?? new ChangeTrackingList(), + schemaModel, + id, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(Schema)} does not support writing '{options.Format}' format."); + } + } + + Schema IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSchema(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(Schema)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static Schema FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSchema(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schema.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schema.cs new file mode 100644 index 000000000000..70b19f8cd4df --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schema.cs @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// SchemaModel. + public partial class Schema + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Schema. + /// is null. + public Schema(IDictionary schemaModel) + { + Argument.AssertNotNull(schemaModel, nameof(schemaModel)); + + Links = new ChangeTrackingList(); + Properties = new ChangeTrackingDictionary(); + DependentCollections = new ChangeTrackingList(); + SchemaModel = schemaModel; + } + + /// Initializes a new instance of . + /// Links for referencing other objects. + /// The ETag value to implement optimistic concurrency. + /// Status of the resource. + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Source of the resource. + /// Name to identify resource. + /// Textual description of the resource. + /// Created by user/tenant id. + /// Modified by user/tenant id. + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// Dependent Collections. + /// Schema. + /// Id of the Schema. + /// Keeps track of any properties unknown to the library. + internal Schema(IList links, string eTag, string status, DateTimeOffset? createdDateTime, DateTimeOffset? modifiedDateTime, string source, string name, string description, string createdBy, string modifiedBy, IDictionary properties, IReadOnlyList dependentCollections, IDictionary schemaModel, string id, IDictionary serializedAdditionalRawData) + { + Links = links; + ETag = eTag; + Status = status; + CreatedDateTime = createdDateTime; + ModifiedDateTime = modifiedDateTime; + Source = source; + Name = name; + Description = description; + CreatedBy = createdBy; + ModifiedBy = modifiedBy; + Properties = properties; + DependentCollections = dependentCollections; + SchemaModel = schemaModel; + Id = id; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal Schema() + { + } + + /// Links for referencing other objects. + public IList Links { get; } + /// The ETag value to implement optimistic concurrency. + public string ETag { get; } + /// Status of the resource. + public string Status { get; set; } + /// Date-time when resource was created, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? CreatedDateTime { get; } + /// Date-time when resource was last modified, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? ModifiedDateTime { get; } + /// Source of the resource. + public string Source { get; set; } + /// Name to identify resource. + public string Name { get; set; } + /// Textual description of the resource. + public string Description { get; set; } + /// Created by user/tenant id. + public string CreatedBy { get; } + /// Modified by user/tenant id. + public string ModifiedBy { get; } + /// + /// 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 150 characters. + /// Note: A maximum of 25 key value pairs can be provided for a resource and only + /// string, + /// numeral and datetime (yyyy-MM-ddTHH:mm:ssZ) values are supported. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary Properties { get; } + /// Dependent Collections. + public IReadOnlyList DependentCollections { get; } + /// + /// Schema. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IDictionary SchemaModel { get; } + /// Id of the Schema. + public string Id { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schemas.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schemas.cs new file mode 100644 index 000000000000..968e46fd117c --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Schemas.cs @@ -0,0 +1,592 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Autorest.CSharp.Core; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The Schemas sub-client. + public partial class Schemas + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Schemas for mocking. + protected Schemas() + { + } + + /// Initializes a new instance of Schemas. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal Schemas(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Gets a specified Schema resource. + /// Id of the Schema. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual async Task> GetSchemaAsync(string schemaId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetSchemaAsync(schemaId, context).ConfigureAwait(false); + return Response.FromValue(Schema.FromResponse(response), response); + } + + /// Gets a specified Schema resource. + /// Id of the Schema. + /// The cancellation token to use. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// + public virtual Response GetSchema(string schemaId, CancellationToken cancellationToken = default) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetSchema(schemaId, context); + return Response.FromValue(Schema.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets a specified Schema resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Schema. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetSchemaAsync(string schemaId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + + using var scope = ClientDiagnostics.CreateScope("Schemas.GetSchema"); + scope.Start(); + try + { + using HttpMessage message = CreateGetSchemaRequest(schemaId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets a specified Schema resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Id of the Schema. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetSchema(string schemaId, RequestContext context) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + + using var scope = ClientDiagnostics.CreateScope("Schemas.GetSchema"); + scope.Start(); + try + { + using HttpMessage message = CreateGetSchemaRequest(schemaId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Schema resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Schema. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateOrUpdateAsync(string schemaId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Schemas.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(schemaId, content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates or updates a Schema resource. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Schema. + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// or is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateOrUpdate(string schemaId, RequestContent content, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Schemas.CreateOrUpdate"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateOrUpdateRequest(schemaId, content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Schema for given Schema id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Schema. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task DeleteAsync(string schemaId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + + using var scope = ClientDiagnostics.CreateScope("Schemas.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(schemaId, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + // The convenience method is omitted here because it has exactly the same parameter list as the corresponding protocol method + /// + /// [Protocol Method] Deletes Schema for given Schema id. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Id of the Schema. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// is an empty string, and was expected to be non-empty. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response Delete(string schemaId, RequestContext context = null) + { + Argument.AssertNotNullOrEmpty(schemaId, nameof(schemaId)); + + using var scope = ClientDiagnostics.CreateScope("Schemas.Delete"); + scope.Start(); + try + { + using HttpMessage message = CreateDeleteRequest(schemaId, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Returns a paginated list of Schema resources. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// + public virtual AsyncPageable GetSchemasAsync(IEnumerable names = null, IEnumerable propertyFilters = null, IEnumerable statuses = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchemasRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchemasNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => Schema.DeserializeSchema(e), ClientDiagnostics, _pipeline, "Schemas.GetSchemas", "value", "nextLink", context); + } + + /// Returns a paginated list of Schema resources. + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The cancellation token to use. + /// + public virtual Pageable GetSchemas(IEnumerable names = null, IEnumerable propertyFilters = null, IEnumerable statuses = null, IEnumerable ids = null, DateTimeOffset? minCreatedDateTime = null, DateTimeOffset? maxCreatedDateTime = null, DateTimeOffset? minLastModifiedDateTime = null, DateTimeOffset? maxLastModifiedDateTime = null, int? maxPageSize = null, string skipToken = null, CancellationToken cancellationToken = default) + { + RequestContext context = cancellationToken.CanBeCanceled ? new RequestContext { CancellationToken = cancellationToken } : null; + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchemasRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchemasNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => Schema.DeserializeSchema(e), ClientDiagnostics, _pipeline, "Schemas.GetSchemas", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Returns a paginated list of Schema resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual AsyncPageable GetSchemasAsync(IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchemasRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchemasNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreateAsyncPageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Schemas.GetSchemas", "value", "nextLink", context); + } + + /// + /// [Protocol Method] Returns a paginated list of Schema resources. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// Names of the resource. + /// + /// Filters on key-value pairs within the Properties object. + /// eg. "{testKey} eq {testValue}". + /// + /// Statuses of the resource. + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// Service returned a non-success status code. + /// The from the service containing a list of objects. Details of the body schema for each item in the collection are in the Remarks section below. + /// + public virtual Pageable GetSchemas(IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + HttpMessage FirstPageRequest(int? pageSizeHint) => CreateGetSchemasRequest(names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + HttpMessage NextPageRequest(int? pageSizeHint, string nextLink) => CreateGetSchemasNextPageRequest(nextLink, names, propertyFilters, statuses, ids, minCreatedDateTime, maxCreatedDateTime, minLastModifiedDateTime, maxLastModifiedDateTime, maxPageSize, skipToken, context); + return GeneratorPageableHelpers.CreatePageable(FirstPageRequest, NextPageRequest, e => BinaryData.FromString(e.GetRawText()), ClientDiagnostics, _pipeline, "Schemas.GetSchemas", "value", "nextLink", context); + } + + internal HttpMessage CreateGetSchemasRequest(IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schemas", false); + uri.AppendQuery("api-version", _apiVersion, true); + if (names != null && !(names is ChangeTrackingList changeTrackingList && changeTrackingList.IsUndefined)) + { + foreach (var param in names) + { + uri.AppendQuery("names", param, true); + } + } + if (propertyFilters != null && !(propertyFilters is ChangeTrackingList changeTrackingList0 && changeTrackingList0.IsUndefined)) + { + foreach (var param in propertyFilters) + { + uri.AppendQuery("propertyFilters", param, true); + } + } + if (statuses != null && !(statuses is ChangeTrackingList changeTrackingList1 && changeTrackingList1.IsUndefined)) + { + foreach (var param in statuses) + { + uri.AppendQuery("statuses", param, true); + } + } + if (ids != null && !(ids is ChangeTrackingList changeTrackingList2 && changeTrackingList2.IsUndefined)) + { + foreach (var param in ids) + { + uri.AppendQuery("ids", param, true); + } + } + if (minCreatedDateTime != null) + { + uri.AppendQuery("minCreatedDateTime", minCreatedDateTime.Value, "O", true); + } + if (maxCreatedDateTime != null) + { + uri.AppendQuery("maxCreatedDateTime", maxCreatedDateTime.Value, "O", true); + } + if (minLastModifiedDateTime != null) + { + uri.AppendQuery("minLastModifiedDateTime", minLastModifiedDateTime.Value, "O", true); + } + if (maxLastModifiedDateTime != null) + { + uri.AppendQuery("maxLastModifiedDateTime", maxLastModifiedDateTime.Value, "O", true); + } + if (maxPageSize != null) + { + uri.AppendQuery("maxPageSize", maxPageSize.Value, true); + } + if (skipToken != null) + { + uri.AppendQuery("skipToken", skipToken, true); + } + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetSchemaRequest(string schemaId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schemas/", false); + uri.AppendPath(schemaId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateCreateOrUpdateRequest(string schemaId, RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200201); + var request = message.Request; + request.Method = RequestMethod.Patch; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schemas/", false); + uri.AppendPath(schemaId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/merge-patch+json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateDeleteRequest(string schemaId, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier204); + var request = message.Request; + request.Method = RequestMethod.Delete; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/schemas/", false); + uri.AppendPath(schemaId, true); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + internal HttpMessage CreateGetSchemasNextPageRequest(string nextLink, IEnumerable names, IEnumerable propertyFilters, IEnumerable statuses, IEnumerable ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Get; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendRawNextLink(nextLink, false); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier200201; + private static ResponseClassifier ResponseClassifier200201 => _responseClassifier200201 ??= new StatusCodeClassifier(stackalloc ushort[] { 200, 201 }); + private static ResponseClassifier _responseClassifier204; + private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchAcrossCollectionRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchAcrossCollectionRequest.Serialization.cs new file mode 100644 index 000000000000..a1eb67a33f8d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchAcrossCollectionRequest.Serialization.cs @@ -0,0 +1,347 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class SearchAcrossCollectionRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchAcrossCollectionRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(OwnerItemIds)) + { + writer.WritePropertyName("ownerItemIds"u8); + writer.WriteStartArray(); + foreach (var item in OwnerItemIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DataFilters)) + { + writer.WritePropertyName("dataFilters"u8); + writer.WriteStartArray(); + foreach (var item in DataFilters) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(IntersectsWithGeometry)) + { + writer.WritePropertyName("intersectsWithGeometry"u8); + writer.WriteObjectValue(IntersectsWithGeometry, options); + } + if (Optional.IsCollectionDefined(Ids)) + { + writer.WritePropertyName("ids"u8); + writer.WriteStartArray(); + foreach (var item in Ids) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(MinCreatedDateTime)) + { + writer.WritePropertyName("minCreatedDateTime"u8); + writer.WriteStringValue(MinCreatedDateTime.Value, "O"); + } + if (Optional.IsDefined(MaxCreatedDateTime)) + { + writer.WritePropertyName("maxCreatedDateTime"u8); + writer.WriteStringValue(MaxCreatedDateTime.Value, "O"); + } + if (Optional.IsDefined(MinLastModifiedDateTime)) + { + writer.WritePropertyName("minLastModifiedDateTime"u8); + writer.WriteStringValue(MinLastModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(MaxLastModifiedDateTime)) + { + writer.WritePropertyName("maxLastModifiedDateTime"u8); + writer.WriteStringValue(MaxLastModifiedDateTime.Value, "O"); + } + if (Optional.IsDefined(MaxPageSize)) + { + writer.WritePropertyName("maxPageSize"u8); + writer.WriteNumberValue(MaxPageSize.Value); + } + if (Optional.IsDefined(SkipToken)) + { + writer.WritePropertyName("skipToken"u8); + writer.WriteStringValue(SkipToken); + } + if (Optional.IsCollectionDefined(CollectionIds)) + { + writer.WritePropertyName("collectionIds"u8); + writer.WriteStartArray(); + foreach (var item in CollectionIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SearchAcrossCollectionRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchAcrossCollectionRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchAcrossCollectionRequest(document.RootElement, options); + } + + internal static SearchAcrossCollectionRequest DeserializeSearchAcrossCollectionRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList ownerItemIds = default; + IReadOnlyList dataFilters = default; + GeoJsonObject intersectsWithGeometry = default; + IReadOnlyList ids = default; + DateTimeOffset? minCreatedDateTime = default; + DateTimeOffset? maxCreatedDateTime = default; + DateTimeOffset? minLastModifiedDateTime = default; + DateTimeOffset? maxLastModifiedDateTime = default; + int? maxPageSize = default; + string skipToken = default; + IReadOnlyList collectionIds = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("ownerItemIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + ownerItemIds = array; + continue; + } + if (property.NameEquals("dataFilters"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dataFilters = array; + continue; + } + if (property.NameEquals("intersectsWithGeometry"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intersectsWithGeometry = GeoJsonObject.DeserializeGeoJsonObject(property.Value, options); + continue; + } + if (property.NameEquals("ids"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + ids = array; + continue; + } + if (property.NameEquals("minCreatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minCreatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("maxCreatedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxCreatedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("minLastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minLastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("maxLastModifiedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxLastModifiedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("maxPageSize"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maxPageSize = property.Value.GetInt32(); + continue; + } + if (property.NameEquals("skipToken"u8)) + { + skipToken = property.Value.GetString(); + continue; + } + if (property.NameEquals("collectionIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + collectionIds = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchAcrossCollectionRequest( + ownerItemIds ?? new ChangeTrackingList(), + dataFilters ?? new ChangeTrackingList(), + intersectsWithGeometry, + ids ?? new ChangeTrackingList(), + minCreatedDateTime, + maxCreatedDateTime, + minLastModifiedDateTime, + maxLastModifiedDateTime, + maxPageSize, + skipToken, + collectionIds ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SearchAcrossCollectionRequest)} does not support writing '{options.Format}' format."); + } + } + + SearchAcrossCollectionRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchAcrossCollectionRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchAcrossCollectionRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SearchAcrossCollectionRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchAcrossCollectionRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchAcrossCollectionRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchAcrossCollectionRequest.cs new file mode 100644 index 000000000000..045a886ba287 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchAcrossCollectionRequest.cs @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The SearchAcrossCollectionRequest. + internal partial class SearchAcrossCollectionRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal SearchAcrossCollectionRequest() + { + OwnerItemIds = new ChangeTrackingList(); + DataFilters = new ChangeTrackingList(); + Ids = new ChangeTrackingList(); + CollectionIds = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Owner Item Ids of the resource. + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// Ids of the resource. + /// Minimum creation date of resource (inclusive). + /// Maximum creation date of resource (inclusive). + /// Minimum last modified date of resource (inclusive). + /// Maximum last modified date of resource (inclusive). + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + /// Skip token for getting next set of results. + /// Owner Item Ids of the resource. + /// Keeps track of any properties unknown to the library. + internal SearchAcrossCollectionRequest(IReadOnlyList ownerItemIds, IReadOnlyList dataFilters, GeoJsonObject intersectsWithGeometry, IReadOnlyList ids, DateTimeOffset? minCreatedDateTime, DateTimeOffset? maxCreatedDateTime, DateTimeOffset? minLastModifiedDateTime, DateTimeOffset? maxLastModifiedDateTime, int? maxPageSize, string skipToken, IReadOnlyList collectionIds, IDictionary serializedAdditionalRawData) + { + OwnerItemIds = ownerItemIds; + DataFilters = dataFilters; + IntersectsWithGeometry = intersectsWithGeometry; + Ids = ids; + MinCreatedDateTime = minCreatedDateTime; + MaxCreatedDateTime = maxCreatedDateTime; + MinLastModifiedDateTime = minLastModifiedDateTime; + MaxLastModifiedDateTime = maxLastModifiedDateTime; + MaxPageSize = maxPageSize; + SkipToken = skipToken; + CollectionIds = collectionIds; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Owner Item Ids of the resource. + public IReadOnlyList OwnerItemIds { get; } + /// + /// Filters on key-value pairs within the Data object. + /// e.g. "{testKey} eq {testValue}". + /// + public IReadOnlyList DataFilters { get; } + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public GeoJsonObject IntersectsWithGeometry { get; } + /// Ids of the resource. + public IReadOnlyList Ids { get; } + /// Minimum creation date of resource (inclusive). + public DateTimeOffset? MinCreatedDateTime { get; } + /// Maximum creation date of resource (inclusive). + public DateTimeOffset? MaxCreatedDateTime { get; } + /// Minimum last modified date of resource (inclusive). + public DateTimeOffset? MinLastModifiedDateTime { get; } + /// Maximum last modified date of resource (inclusive). + public DateTimeOffset? MaxLastModifiedDateTime { get; } + /// + /// Maximum number of items needed (inclusive). + /// Minimum = 10, Maximum = 1000, Default value = 50. + /// + public int? MaxPageSize { get; } + /// Skip token for getting next set of results. + public string SkipToken { get; } + /// Owner Item Ids of the resource. + public IReadOnlyList CollectionIds { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchFeaturesResponse.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchFeaturesResponse.Serialization.cs new file mode 100644 index 000000000000..5cf48a98188d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchFeaturesResponse.Serialization.cs @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class SearchFeaturesResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchFeaturesResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("features"u8); + writer.WriteStartArray(); + foreach (var item in Features) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + if (options.Format != "W" && Optional.IsDefined(NextLink)) + { + writer.WritePropertyName("nextLink"u8); + writer.WriteStringValue(NextLink); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SearchFeaturesResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchFeaturesResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchFeaturesResponse(document.RootElement, options); + } + + internal static SearchFeaturesResponse DeserializeSearchFeaturesResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList features = default; + string nextLink = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("features"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StacItem.DeserializeStacItem(item, options)); + } + features = array; + continue; + } + if (property.NameEquals("nextLink"u8)) + { + nextLink = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchFeaturesResponse(features, nextLink, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SearchFeaturesResponse)} does not support writing '{options.Format}' format."); + } + } + + SearchFeaturesResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchFeaturesResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchFeaturesResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SearchFeaturesResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchFeaturesResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchFeaturesResponse.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchFeaturesResponse.cs new file mode 100644 index 000000000000..59d097b05580 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchFeaturesResponse.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + /// + /// Paged response contains list of items and next property to get the next set of + /// results. + /// + public partial class SearchFeaturesResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// List of items. + /// is null. + internal SearchFeaturesResponse(IEnumerable features) + { + Argument.AssertNotNull(features, nameof(features)); + + Features = features.ToList(); + } + + /// Initializes a new instance of . + /// List of items. + /// + /// URL to do the POST request with same filters, + /// to get next set of items. + /// + /// Keeps track of any properties unknown to the library. + internal SearchFeaturesResponse(IReadOnlyList features, string nextLink, IDictionary serializedAdditionalRawData) + { + Features = features; + NextLink = nextLink; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchFeaturesResponse() + { + } + + /// List of items. + public IReadOnlyList Features { get; } + /// + /// URL to do the POST request with same filters, + /// to get next set of items. + /// + public string NextLink { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchItemsRequest.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchItemsRequest.Serialization.cs new file mode 100644 index 000000000000..c6e9e6c9947c --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchItemsRequest.Serialization.cs @@ -0,0 +1,262 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class SearchItemsRequest : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchItemsRequest)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(StartDateTime)) + { + writer.WritePropertyName("startDateTime"u8); + writer.WriteStringValue(StartDateTime.Value, "O"); + } + writer.WritePropertyName("credentials"u8); + writer.WriteObjectValue(Credentials, options); + writer.WritePropertyName("provider"u8); + writer.WriteStringValue(Provider); + if (Optional.IsDefined(EndDateTime)) + { + writer.WritePropertyName("endDateTime"u8); + writer.WriteStringValue(EndDateTime.Value, "O"); + } + if (Optional.IsDefined(Intersects)) + { + writer.WritePropertyName("intersects"u8); + writer.WriteObjectValue(Intersects, options); + } + if (Optional.IsCollectionDefined(Bbox)) + { + writer.WritePropertyName("bbox"u8); + writer.WriteStartArray(); + foreach (var item in Bbox) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(FeatureIds)) + { + writer.WritePropertyName("featureIds"u8); + writer.WriteStartArray(); + foreach (var item in FeatureIds) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("providerCollectionId"u8); + writer.WriteStringValue(ProviderCollectionId); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + SearchItemsRequest IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(SearchItemsRequest)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeSearchItemsRequest(document.RootElement, options); + } + + internal static SearchItemsRequest DeserializeSearchItemsRequest(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset? startDateTime = default; + OauthClientCredentials credentials = default; + string provider = default; + DateTimeOffset? endDateTime = default; + GeoJsonObject intersects = default; + IReadOnlyList bbox = default; + IReadOnlyList featureIds = default; + string providerCollectionId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("startDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + startDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("credentials"u8)) + { + credentials = OauthClientCredentials.DeserializeOauthClientCredentials(property.Value, options); + continue; + } + if (property.NameEquals("provider"u8)) + { + provider = property.Value.GetString(); + continue; + } + if (property.NameEquals("endDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + endDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("intersects"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + intersects = GeoJsonObject.DeserializeGeoJsonObject(property.Value, options); + continue; + } + if (property.NameEquals("bbox"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + bbox = array; + continue; + } + if (property.NameEquals("featureIds"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + featureIds = array; + continue; + } + if (property.NameEquals("providerCollectionId"u8)) + { + providerCollectionId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new SearchItemsRequest( + startDateTime, + credentials, + provider, + endDateTime, + intersects, + bbox ?? new ChangeTrackingList(), + featureIds ?? new ChangeTrackingList(), + providerCollectionId, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(SearchItemsRequest)} does not support writing '{options.Format}' format."); + } + } + + SearchItemsRequest IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchItemsRequest(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(SearchItemsRequest)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static SearchItemsRequest FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeSearchItemsRequest(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchItemsRequest.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchItemsRequest.cs new file mode 100644 index 000000000000..8b03757e0b61 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/SearchItemsRequest.cs @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// The SearchItemsRequest. + internal partial class SearchItemsRequest + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// OAuthClientCredentials for clientId clientSecret auth. + /// Provider of satellite data. Available Value: SentinelHub. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// , or is null. + internal SearchItemsRequest(OauthClientCredentials credentials, string provider, string providerCollectionId) + { + Argument.AssertNotNull(credentials, nameof(credentials)); + Argument.AssertNotNull(provider, nameof(provider)); + Argument.AssertNotNull(providerCollectionId, nameof(providerCollectionId)); + + Credentials = credentials; + Provider = provider; + Bbox = new ChangeTrackingList(); + FeatureIds = new ChangeTrackingList(); + ProviderCollectionId = providerCollectionId; + } + + /// Initializes a new instance of . + /// Start datetime of the time interval in which to search for Items. + /// OAuthClientCredentials for clientId clientSecret auth. + /// Provider of satellite data. Available Value: SentinelHub. + /// End datetime of the time interval in which to search for Items. + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + /// + /// Only items that have a geometry that intersects the bounding box are selected. + /// The bounding box is provided as four numbers. The coordinate reference system + /// of the values is WGS84 longitude/latitude. + /// + /// Array of feature ids to return. + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + /// Keeps track of any properties unknown to the library. + internal SearchItemsRequest(DateTimeOffset? startDateTime, OauthClientCredentials credentials, string provider, DateTimeOffset? endDateTime, GeoJsonObject intersects, IReadOnlyList bbox, IReadOnlyList featureIds, string providerCollectionId, IDictionary serializedAdditionalRawData) + { + StartDateTime = startDateTime; + Credentials = credentials; + Provider = provider; + EndDateTime = endDateTime; + Intersects = intersects; + Bbox = bbox; + FeatureIds = featureIds; + ProviderCollectionId = providerCollectionId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal SearchItemsRequest() + { + } + + /// Start datetime of the time interval in which to search for Items. + public DateTimeOffset? StartDateTime { get; } + /// OAuthClientCredentials for clientId clientSecret auth. + public OauthClientCredentials Credentials { get; } + /// Provider of satellite data. Available Value: SentinelHub. + public string Provider { get; } + /// End datetime of the time interval in which to search for Items. + public DateTimeOffset? EndDateTime { get; } + /// + /// GeoJSON (For more details: https://geojson.org/). Note: Coordinates are + /// expected in [Longitude, Latitude] format. + /// Please note is the base class. According to the scenario, a derived class of the base class might need to be assigned here, or this property needs to be casted to one of the possible derived classes. + /// The available derived classes include , and . + /// + public GeoJsonObject Intersects { get; } + /// + /// Only items that have a geometry that intersects the bounding box are selected. + /// The bounding box is provided as four numbers. The coordinate reference system + /// of the values is WGS84 longitude/latitude. + /// + public IReadOnlyList Bbox { get; } + /// Array of feature ids to return. + public IReadOnlyList FeatureIds { get; } + /// Collection of satellite data. Available Value: sentinel-2-l2a, sentinel-2-l1c. + public string ProviderCollectionId { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Solutions.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Solutions.cs new file mode 100644 index 000000000000..d19fccf5962f --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Solutions.cs @@ -0,0 +1,645 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The Solutions sub-client. + public partial class Solutions + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Solutions for mocking. + protected Solutions() + { + } + + /// Initializes a new instance of Solutions. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal Solutions(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Cancel Solution job Async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// The cancellation token to use. + /// , , or is null. + /// + public virtual async Task> CancelJobAsync(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + + CancelJobRequest cancelJobRequest = new CancelJobRequest(solutionId, requestPath, partnerRequestBody, partnerRequestHeaders, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CancelJobAsync(cancelJobRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// Cancel Solution job Async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// The cancellation token to use. + /// , , or is null. + /// + public virtual Response CancelJob(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + + CancelJobRequest cancelJobRequest = new CancelJobRequest(solutionId, requestPath, partnerRequestBody, partnerRequestHeaders, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CancelJob(cancelJobRequest.ToRequestContent(), context); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Cancel Solution job Async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CancelJobAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.CancelJob"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelJobRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Cancel Solution job Async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CancelJob(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.CancelJob"); + scope.Start(); + try + { + using HttpMessage message = CreateCancelJobRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Creates solution job async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// The cancellation token to use. + /// , , , or is null. + /// + public virtual async Task> CreateJobAsync(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + Argument.AssertNotNull(inputData, nameof(inputData)); + + CreateJobRequest createJobRequest = new CreateJobRequest( + solutionId, + requestPath, + partnerRequestBody, + partnerRequestHeaders, + inputData, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await CreateJobAsync(createJobRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// Creates solution job async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// The cancellation token to use. + /// , , , or is null. + /// + public virtual Response CreateJob(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + Argument.AssertNotNull(inputData, nameof(inputData)); + + CreateJobRequest createJobRequest = new CreateJobRequest( + solutionId, + requestPath, + partnerRequestBody, + partnerRequestHeaders, + inputData, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = CreateJob(createJobRequest.ToRequestContent(), context); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Creates solution job async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task CreateJobAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.CreateJob"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateJobRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Creates solution job async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response CreateJob(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.CreateJob"); + scope.Start(); + try + { + using HttpMessage message = CreateCreateJobRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets solution Data async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// The cancellation token to use. + /// , , , or is null. + /// + public virtual async Task> GetDataAsync(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + Argument.AssertNotNull(inputData, nameof(inputData)); + + GetDataRequest getDataRequest = new GetDataRequest( + solutionId, + requestPath, + partnerRequestBody, + partnerRequestHeaders, + inputData, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetDataAsync(getDataRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// Gets solution Data async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// Input Data. + /// The cancellation token to use. + /// , , , or is null. + /// + public virtual Response GetData(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, IReadOnlyDictionary inputData, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + Argument.AssertNotNull(inputData, nameof(inputData)); + + GetDataRequest getDataRequest = new GetDataRequest( + solutionId, + requestPath, + partnerRequestBody, + partnerRequestHeaders, + inputData, + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetData(getDataRequest.ToRequestContent(), context); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets solution Data async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetDataAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.GetData"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDataRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets solution Data async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetData(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.GetData"); + scope.Start(); + try + { + using HttpMessage message = CreateGetDataRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// Gets Solution get job response async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// The cancellation token to use. + /// , , or is null. + /// + public virtual async Task> GetJobAsync(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + + GetJobRequest getJobRequest = new GetJobRequest(solutionId, requestPath, partnerRequestBody, partnerRequestHeaders, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetJobAsync(getJobRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// Gets Solution get job response async. + /// SolutionId. + /// RequestPath. + /// Properties. + /// Properties. + /// The cancellation token to use. + /// , , or is null. + /// + public virtual Response GetJob(string solutionId, string requestPath, IReadOnlyDictionary partnerRequestBody, IReadOnlyDictionary partnerRequestHeaders, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(solutionId, nameof(solutionId)); + Argument.AssertNotNull(requestPath, nameof(requestPath)); + Argument.AssertNotNull(partnerRequestBody, nameof(partnerRequestBody)); + Argument.AssertNotNull(partnerRequestHeaders, nameof(partnerRequestHeaders)); + + GetJobRequest getJobRequest = new GetJobRequest(solutionId, requestPath, partnerRequestBody, partnerRequestHeaders, null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetJob(getJobRequest.ToRequestContent(), context); + return Response.FromValue(SamplePartnerResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Gets Solution get job response async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetJobAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.GetJob"); + scope.Start(); + try + { + using HttpMessage message = CreateGetJobRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Gets Solution get job response async. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetJob(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Solutions.GetJob"); + scope.Start(); + try + { + using HttpMessage message = CreateGetJobRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateCancelJobRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/external/solutions:cancel-job", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateCreateJobRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier202); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/external/solutions:create-job", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetDataRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/external/solutions:get-data", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + internal HttpMessage CreateGetJobRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/external/solutions:get-job", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + private static ResponseClassifier _responseClassifier202; + private static ResponseClassifier ResponseClassifier202 => _responseClassifier202 ??= new StatusCodeClassifier(stackalloc ushort[] { 202 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacAsset.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacAsset.Serialization.cs new file mode 100644 index 000000000000..4a38e4bf9d3f --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacAsset.Serialization.cs @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class StacAsset : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StacAsset)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Href)) + { + writer.WritePropertyName("href"u8); + writer.WriteStringValue(Href); + } + if (Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (Optional.IsDefined(Description)) + { + writer.WritePropertyName("description"u8); + writer.WriteStringValue(Description); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (Optional.IsCollectionDefined(Roles)) + { + writer.WritePropertyName("roles"u8); + writer.WriteStartArray(); + foreach (var item in Roles) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + StacAsset IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StacAsset)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStacAsset(document.RootElement, options); + } + + internal static StacAsset DeserializeStacAsset(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string href = default; + string title = default; + string description = default; + string type = default; + IReadOnlyList roles = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("href"u8)) + { + href = property.Value.GetString(); + continue; + } + if (property.NameEquals("title"u8)) + { + title = property.Value.GetString(); + continue; + } + if (property.NameEquals("description"u8)) + { + description = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("roles"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + roles = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StacAsset( + href, + title, + description, + type, + roles ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StacAsset)} does not support writing '{options.Format}' format."); + } + } + + StacAsset IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStacAsset(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StacAsset)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static StacAsset FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStacAsset(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacAsset.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacAsset.cs new file mode 100644 index 000000000000..a6a096f56fd2 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacAsset.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Assets. + public partial class StacAsset + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal StacAsset() + { + Roles = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// The HREF of the asset. + /// The title of the asset. + /// The description of the asset. + /// The type of the asset. + /// The roles of the asset. + /// Keeps track of any properties unknown to the library. + internal StacAsset(string href, string title, string description, string type, IReadOnlyList roles, IDictionary serializedAdditionalRawData) + { + Href = href; + Title = title; + Description = description; + Type = type; + Roles = roles; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The HREF of the asset. + public string Href { get; } + /// The title of the asset. + public string Title { get; } + /// The description of the asset. + public string Description { get; } + /// The type of the asset. + public string Type { get; } + /// The roles of the asset. + public IReadOnlyList Roles { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacItem.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacItem.Serialization.cs new file mode 100644 index 000000000000..736d01cd63be --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacItem.Serialization.cs @@ -0,0 +1,304 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class StacItem : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StacItem)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("stacVersion"u8); + writer.WriteStringValue(StacVersion); + if (Optional.IsCollectionDefined(StacExtensions)) + { + writer.WritePropertyName("stacExtensions"u8); + writer.WriteStartArray(); + foreach (var item in StacExtensions) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("id"u8); + writer.WriteStringValue(Id); + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + if (Optional.IsDefined(Geometry)) + { + writer.WritePropertyName("geometry"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Geometry); +#else + using (JsonDocument document = JsonDocument.Parse(Geometry, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + if (Optional.IsCollectionDefined(Bbox)) + { + writer.WritePropertyName("bbox"u8); + writer.WriteStartArray(); + foreach (var item in Bbox) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + writer.WritePropertyName("properties"u8); +#if NET6_0_OR_GREATER + writer.WriteRawValue(Properties); +#else + using (JsonDocument document = JsonDocument.Parse(Properties, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + writer.WritePropertyName("links"u8); + writer.WriteStartArray(); + foreach (var item in Links) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + writer.WritePropertyName("assets"u8); + writer.WriteStartObject(); + foreach (var item in Assets) + { + writer.WritePropertyName(item.Key); + writer.WriteObjectValue(item.Value, options); + } + writer.WriteEndObject(); + if (Optional.IsDefined(ProviderCollectionId)) + { + writer.WritePropertyName("providerCollectionId"u8); + writer.WriteStringValue(ProviderCollectionId); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + StacItem IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StacItem)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStacItem(document.RootElement, options); + } + + internal static StacItem DeserializeStacItem(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string stacVersion = default; + IReadOnlyList stacExtensions = default; + string id = default; + string type = default; + BinaryData geometry = default; + IReadOnlyList bbox = default; + BinaryData properties = default; + IReadOnlyList links = default; + IReadOnlyDictionary assets = default; + string providerCollectionId = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("stacVersion"u8)) + { + stacVersion = property.Value.GetString(); + continue; + } + if (property.NameEquals("stacExtensions"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + stacExtensions = array; + continue; + } + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("geometry"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + geometry = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("bbox"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + bbox = array; + continue; + } + if (property.NameEquals("properties"u8)) + { + properties = BinaryData.FromString(property.Value.GetRawText()); + continue; + } + if (property.NameEquals("links"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(StacLink.DeserializeStacLink(item, options)); + } + links = array; + continue; + } + if (property.NameEquals("assets"u8)) + { + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + dictionary.Add(property0.Name, StacAsset.DeserializeStacAsset(property0.Value, options)); + } + assets = dictionary; + continue; + } + if (property.NameEquals("providerCollectionId"u8)) + { + providerCollectionId = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StacItem( + stacVersion, + stacExtensions ?? new ChangeTrackingList(), + id, + type, + geometry, + bbox ?? new ChangeTrackingList(), + properties, + links, + assets, + providerCollectionId, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StacItem)} does not support writing '{options.Format}' format."); + } + } + + StacItem IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStacItem(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StacItem)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static StacItem FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStacItem(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacItem.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacItem.cs new file mode 100644 index 000000000000..2b654aef5e2f --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacItem.cs @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.AgriculturePlatform +{ + /// + /// Schema of STAC Item. + /// Refer for spec: + /// https://github.com/radiantearth/stac-spec/blob/v1.0.0-beta.2/item-spec/item-spec.md#item-fields. + /// + public partial class StacItem + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// The STAC version the Stac Item implements. + /// Provider identifier. Globally unique ID by Data provider. + /// Type of the GeoJSON Object. It's value is always Feature. + /// A dictionary of additional metadata for the item. + /// List of link objects to resources and related URLs. + /// Dictionary of asset objects, each with a unique key. + /// , , , , or is null. + internal StacItem(string stacVersion, string id, string type, BinaryData properties, IEnumerable links, IReadOnlyDictionary assets) + { + Argument.AssertNotNull(stacVersion, nameof(stacVersion)); + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(type, nameof(type)); + Argument.AssertNotNull(properties, nameof(properties)); + Argument.AssertNotNull(links, nameof(links)); + Argument.AssertNotNull(assets, nameof(assets)); + + StacVersion = stacVersion; + StacExtensions = new ChangeTrackingList(); + Id = id; + Type = type; + Bbox = new ChangeTrackingList(); + Properties = properties; + Links = links.ToList(); + Assets = assets; + } + + /// Initializes a new instance of . + /// The STAC version the Stac Item implements. + /// A list of extensions the Stac Item implements. + /// Provider identifier. Globally unique ID by Data provider. + /// Type of the GeoJSON Object. It's value is always Feature. + /// + /// Defines the full footprint of the asset represented by this item. + /// Its a GeoJSON geometry. + /// + /// Bounding box of the item. + /// A dictionary of additional metadata for the item. + /// List of link objects to resources and related URLs. + /// Dictionary of asset objects, each with a unique key. + /// The id of the STAC Collection this Stac Item references. + /// Keeps track of any properties unknown to the library. + internal StacItem(string stacVersion, IReadOnlyList stacExtensions, string id, string type, BinaryData geometry, IReadOnlyList bbox, BinaryData properties, IReadOnlyList links, IReadOnlyDictionary assets, string providerCollectionId, IDictionary serializedAdditionalRawData) + { + StacVersion = stacVersion; + StacExtensions = stacExtensions; + Id = id; + Type = type; + Geometry = geometry; + Bbox = bbox; + Properties = properties; + Links = links; + Assets = assets; + ProviderCollectionId = providerCollectionId; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal StacItem() + { + } + + /// The STAC version the Stac Item implements. + public string StacVersion { get; } + /// A list of extensions the Stac Item implements. + public IReadOnlyList StacExtensions { get; } + /// Provider identifier. Globally unique ID by Data provider. + public string Id { get; } + /// Type of the GeoJSON Object. It's value is always Feature. + public string Type { get; } + /// + /// Defines the full footprint of the asset represented by this item. + /// Its a GeoJSON geometry. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Geometry { get; } + /// Bounding box of the item. + public IReadOnlyList Bbox { get; } + /// + /// A dictionary of additional metadata for the item. + /// + /// To assign an object to this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public BinaryData Properties { get; } + /// List of link objects to resources and related URLs. + public IReadOnlyList Links { get; } + /// Dictionary of asset objects, each with a unique key. + public IReadOnlyDictionary Assets { get; } + /// The id of the STAC Collection this Stac Item references. + public string ProviderCollectionId { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacLink.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacLink.Serialization.cs new file mode 100644 index 000000000000..f7d865e8541d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacLink.Serialization.cs @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class StacLink : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StacLink)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Href)) + { + writer.WritePropertyName("href"u8); + writer.WriteStringValue(Href); + } + if (Optional.IsDefined(Rel)) + { + writer.WritePropertyName("rel"u8); + writer.WriteStringValue(Rel); + } + if (Optional.IsDefined(Type)) + { + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + } + if (Optional.IsDefined(Title)) + { + writer.WritePropertyName("title"u8); + writer.WriteStringValue(Title); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + StacLink IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(StacLink)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeStacLink(document.RootElement, options); + } + + internal static StacLink DeserializeStacLink(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string href = default; + string rel = default; + string type = default; + string title = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("href"u8)) + { + href = property.Value.GetString(); + continue; + } + if (property.NameEquals("rel"u8)) + { + rel = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("title"u8)) + { + title = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new StacLink(href, rel, type, title, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(StacLink)} does not support writing '{options.Format}' format."); + } + } + + StacLink IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStacLink(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(StacLink)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static StacLink FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeStacLink(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacLink.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacLink.cs new file mode 100644 index 000000000000..e5be64afba9d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/StacLink.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Link. + public partial class StacLink + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal StacLink() + { + } + + /// Initializes a new instance of . + /// The HREF of the link. + /// The relation type of the link. + /// The type of the link. Optional. + /// The title of the link. Optional. + /// Keeps track of any properties unknown to the library. + internal StacLink(string href, string rel, string type, string title, IDictionary serializedAdditionalRawData) + { + Href = href; + Rel = rel; + Type = type; + Title = title; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// The HREF of the link. + public string Href { get; } + /// The relation type of the link. + public string Rel { get; } + /// The type of the link. Optional. + public string Type { get; } + /// The title of the link. Optional. + public string Title { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownAuthCredentials.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownAuthCredentials.Serialization.cs new file mode 100644 index 000000000000..ff3b8d48c6fb --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownAuthCredentials.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class UnknownAuthCredentials : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthCredentials)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + AuthCredentials IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(AuthCredentials)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeAuthCredentials(document.RootElement, options); + } + + internal static UnknownAuthCredentials DeserializeUnknownAuthCredentials(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AuthCredentialsKind kind = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("kind"u8)) + { + kind = new AuthCredentialsKind(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownAuthCredentials(kind, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(AuthCredentials)} does not support writing '{options.Format}' format."); + } + } + + AuthCredentials IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeAuthCredentials(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(AuthCredentials)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownAuthCredentials FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownAuthCredentials(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownAuthCredentials.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownAuthCredentials.cs new file mode 100644 index 000000000000..288ec00f382d --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownAuthCredentials.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Unknown version of AuthCredentials. + internal partial class UnknownAuthCredentials : AuthCredentials + { + /// Initializes a new instance of . + /// Enum for different types of AuthCredentials supported. + /// Keeps track of any properties unknown to the library. + internal UnknownAuthCredentials(AuthCredentialsKind kind, IDictionary serializedAdditionalRawData) : base(kind, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownAuthCredentials() + { + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownGeoJsonObject.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownGeoJsonObject.Serialization.cs new file mode 100644 index 000000000000..5017c98bd713 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownGeoJsonObject.Serialization.cs @@ -0,0 +1,126 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + internal partial class UnknownGeoJsonObject : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support writing '{format}' format."); + } + + base.JsonModelWriteCore(writer, options); + } + + GeoJsonObject IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeGeoJsonObject(document.RootElement, options); + } + + internal static UnknownGeoJsonObject DeserializeUnknownGeoJsonObject(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + GeoJsonObjectType type = "Unknown"; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = new GeoJsonObjectType(property.Value.GetString()); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new UnknownGeoJsonObject(type, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support writing '{options.Format}' format."); + } + } + + GeoJsonObject IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeGeoJsonObject(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(GeoJsonObject)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static new UnknownGeoJsonObject FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeUnknownGeoJsonObject(document.RootElement); + } + + /// Convert into a . + internal override RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownGeoJsonObject.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownGeoJsonObject.cs new file mode 100644 index 000000000000..f3e2008ee5bb --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/UnknownGeoJsonObject.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Unknown version of GeoJsonObject. + internal partial class UnknownGeoJsonObject : GeoJsonObject + { + /// Initializes a new instance of . + /// Type of GeoJSON object. + /// Keeps track of any properties unknown to the library. + internal UnknownGeoJsonObject(GeoJsonObjectType type, IDictionary serializedAdditionalRawData) : base(type, serializedAdditionalRawData) + { + } + + /// Initializes a new instance of for deserialization. + internal UnknownGeoJsonObject() + { + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Weather.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Weather.cs new file mode 100644 index 000000000000..a363b56addd7 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/Weather.cs @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; + +namespace Azure.AgriculturePlatform +{ + // Data plane generated sub-client. + /// The Weather sub-client. + public partial class Weather + { + private const string AuthorizationHeader = "Authorization"; + private readonly AzureKeyCredential _keyCredential; + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + private readonly string _apiVersion; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// The HTTP pipeline for sending and receiving REST requests and responses. + public virtual HttpPipeline Pipeline => _pipeline; + + /// Initializes a new instance of Weather for mocking. + protected Weather() + { + } + + /// Initializes a new instance of Weather. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The key credential to copy. + /// The to use. + /// The API version to use for this operation. + internal Weather(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, AzureKeyCredential keyCredential, Uri endpoint, string apiVersion) + { + ClientDiagnostics = clientDiagnostics; + _pipeline = pipeline; + _keyCredential = keyCredential; + _endpoint = endpoint; + _apiVersion = apiVersion; + } + + /// Returns a list of WeatherData. + /// Weather provider name. + /// Provider's api name to which request is to be made. + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + /// + /// Language (IETF BCP 47 language tag) in which search results should be returned + /// by the data provider. Examples: 'en-US', 'es', 'es-MX', 'fr-FR'. + /// + /// Api Key Auth Credentials class for API Key based Auth. + /// List of locations for which weather data need to be fetched from the provider. + /// The cancellation token to use. + /// , or is null. + /// + public virtual async Task> GetWeatherOperationAsync(string providerName, string providerApiName, string units, string language = null, ApiKeyAuthCredentials credentials = null, IEnumerable locations = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(providerName, nameof(providerName)); + Argument.AssertNotNull(providerApiName, nameof(providerApiName)); + Argument.AssertNotNull(units, nameof(units)); + + GetRequest getRequest = new GetRequest( + providerName, + providerApiName, + language, + units, + credentials, + locations?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = await GetWeatherOperationAsync(getRequest.ToRequestContent(), context).ConfigureAwait(false); + return Response.FromValue(WeatherResponse.FromResponse(response), response); + } + + /// Returns a list of WeatherData. + /// Weather provider name. + /// Provider's api name to which request is to be made. + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + /// + /// Language (IETF BCP 47 language tag) in which search results should be returned + /// by the data provider. Examples: 'en-US', 'es', 'es-MX', 'fr-FR'. + /// + /// Api Key Auth Credentials class for API Key based Auth. + /// List of locations for which weather data need to be fetched from the provider. + /// The cancellation token to use. + /// , or is null. + /// + public virtual Response GetWeatherOperation(string providerName, string providerApiName, string units, string language = null, ApiKeyAuthCredentials credentials = null, IEnumerable locations = null, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(providerName, nameof(providerName)); + Argument.AssertNotNull(providerApiName, nameof(providerApiName)); + Argument.AssertNotNull(units, nameof(units)); + + GetRequest getRequest = new GetRequest( + providerName, + providerApiName, + language, + units, + credentials, + locations?.ToList() as IReadOnlyList ?? new ChangeTrackingList(), + null); + RequestContext context = FromCancellationToken(cancellationToken); + Response response = GetWeatherOperation(getRequest.ToRequestContent(), context); + return Response.FromValue(WeatherResponse.FromResponse(response), response); + } + + /// + /// [Protocol Method] Returns a list of WeatherData. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual async Task GetWeatherOperationAsync(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Weather.GetWeatherOperation"); + scope.Start(); + try + { + using HttpMessage message = CreateGetWeatherOperationRequest(content, context); + return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + /// + /// [Protocol Method] Returns a list of WeatherData. + /// + /// + /// + /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. + /// + /// + /// + /// + /// Please try the simpler convenience overload with strongly typed models first. + /// + /// + /// + /// + /// The content to send as the body of the request. + /// The request context, which can override default behaviors of the client pipeline on a per-call basis. + /// is null. + /// Service returned a non-success status code. + /// The response returned from the service. + /// + public virtual Response GetWeatherOperation(RequestContent content, RequestContext context = null) + { + Argument.AssertNotNull(content, nameof(content)); + + using var scope = ClientDiagnostics.CreateScope("Weather.GetWeatherOperation"); + scope.Start(); + try + { + using HttpMessage message = CreateGetWeatherOperationRequest(content, context); + return _pipeline.ProcessMessage(message, context); + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + internal HttpMessage CreateGetWeatherOperationRequest(RequestContent content, RequestContext context) + { + var message = _pipeline.CreateMessage(context, ResponseClassifier200); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/external/weather:fetch", false); + uri.AppendQuery("api-version", _apiVersion, true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + request.Content = content; + return message; + } + + private static RequestContext DefaultRequestContext = new RequestContext(); + internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) + { + if (!cancellationToken.CanBeCanceled) + { + return DefaultRequestContext; + } + + return new RequestContext() { CancellationToken = cancellationToken }; + } + + private static ResponseClassifier _responseClassifier200; + private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherData.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherData.Serialization.cs new file mode 100644 index 000000000000..aba03b45cbb6 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherData.Serialization.cs @@ -0,0 +1,701 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class WeatherData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherData)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(AdditionalAttributes)) + { + writer.WritePropertyName("additionalAttributes"u8); + writer.WriteStartObject(); + foreach (var item in AdditionalAttributes) + { + writer.WritePropertyName(item.Key); + if (item.Value == null) + { + writer.WriteNullValue(); + continue; + } +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + writer.WriteEndObject(); + } + if (Optional.IsDefined(WetBulbTemperature)) + { + writer.WritePropertyName("wetBulbTemperature"u8); + writer.WriteObjectValue(WetBulbTemperature, options); + } + if (Optional.IsDefined(CloudCover)) + { + writer.WritePropertyName("cloudCover"u8); + writer.WriteObjectValue(CloudCover, options); + } + if (Optional.IsCollectionDefined(DayOfWeek)) + { + writer.WritePropertyName("dayOfWeek"u8); + writer.WriteStartArray(); + foreach (var item in DayOfWeek) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(DayOrNight)) + { + writer.WritePropertyName("dayOrNight"u8); + writer.WriteStartArray(); + foreach (var item in DayOrNight) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ExpirationTime)) + { + writer.WritePropertyName("expirationTime"u8); + writer.WriteStartArray(); + foreach (var item in ExpirationTime) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(IconCode)) + { + writer.WritePropertyName("iconCode"u8); + writer.WriteStartArray(); + foreach (var item in IconCode) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(IconCodeExtend)) + { + writer.WritePropertyName("iconCodeExtend"u8); + writer.WriteStartArray(); + foreach (var item in IconCodeExtend) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(HasPrecipitation)) + { + writer.WritePropertyName("hasPrecipitation"u8); + writer.WriteStartArray(); + foreach (var item in HasPrecipitation) + { + writer.WriteBooleanValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(PressureMeanSeaLevel)) + { + writer.WritePropertyName("pressureMeanSeaLevel"u8); + writer.WriteObjectValue(PressureMeanSeaLevel, options); + } + if (Optional.IsDefined(RelativeHumidity)) + { + writer.WritePropertyName("relativeHumidity"u8); + writer.WriteObjectValue(RelativeHumidity, options); + } + if (Optional.IsDefined(Temperature)) + { + writer.WritePropertyName("temperature"u8); + writer.WriteObjectValue(Temperature, options); + } + if (Optional.IsDefined(TemperatureDewPoint)) + { + writer.WritePropertyName("temperatureDewPoint"u8); + writer.WriteObjectValue(TemperatureDewPoint, options); + } + if (Optional.IsDefined(TemperatureFeelsLike)) + { + writer.WritePropertyName("temperatureFeelsLike"u8); + writer.WriteObjectValue(TemperatureFeelsLike, options); + } + if (Optional.IsDefined(TemperatureHeatIndex)) + { + writer.WritePropertyName("temperatureHeatIndex"u8); + writer.WriteObjectValue(TemperatureHeatIndex, options); + } + if (Optional.IsDefined(TemperatureWindChill)) + { + writer.WritePropertyName("temperatureWindChill"u8); + writer.WriteObjectValue(TemperatureWindChill, options); + } + if (Optional.IsCollectionDefined(UvDescription)) + { + writer.WritePropertyName("uvDescription"u8); + writer.WriteStartArray(); + foreach (var item in UvDescription) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(UvIndex)) + { + writer.WritePropertyName("uvIndex"u8); + writer.WriteStartArray(); + foreach (var item in UvIndex) + { + writer.WriteNumberValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ValidTimeLocal)) + { + writer.WritePropertyName("validTimeLocal"u8); + writer.WriteStartArray(); + foreach (var item in ValidTimeLocal) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(ValidTime)) + { + writer.WritePropertyName("validTime"u8); + writer.WriteStartArray(); + foreach (var item in ValidTime) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Visibility)) + { + writer.WritePropertyName("visibility"u8); + writer.WriteObjectValue(Visibility, options); + } + if (Optional.IsDefined(WindDirection)) + { + writer.WritePropertyName("windDirection"u8); + writer.WriteObjectValue(WindDirection, options); + } + if (Optional.IsDefined(WindGust)) + { + writer.WritePropertyName("windGust"u8); + writer.WriteObjectValue(WindGust, options); + } + if (Optional.IsDefined(WindSpeed)) + { + writer.WritePropertyName("windSpeed"u8); + writer.WriteObjectValue(WindSpeed, options); + } + if (Optional.IsCollectionDefined(WxPhraseLong)) + { + writer.WritePropertyName("wxPhraseLong"u8); + writer.WriteStartArray(); + foreach (var item in WxPhraseLong) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (Optional.IsCollectionDefined(WxPhraseShort)) + { + writer.WritePropertyName("wxPhraseShort"u8); + writer.WriteStartArray(); + foreach (var item in WxPhraseShort) + { + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WeatherData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeatherData(document.RootElement, options); + } + + internal static WeatherData DeserializeWeatherData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyDictionary additionalAttributes = default; + Measures wetBulbTemperature = default; + Measures cloudCover = default; + IReadOnlyList dayOfWeek = default; + IReadOnlyList dayOrNight = default; + IReadOnlyList expirationTime = default; + IReadOnlyList iconCode = default; + IReadOnlyList iconCodeExtend = default; + IReadOnlyList hasPrecipitation = default; + Measures pressureMeanSeaLevel = default; + Measures relativeHumidity = default; + Measures temperature = default; + Measures temperatureDewPoint = default; + Measures temperatureFeelsLike = default; + Measures temperatureHeatIndex = default; + Measures temperatureWindChill = default; + IReadOnlyList uvDescription = default; + IReadOnlyList uvIndex = default; + IReadOnlyList validTimeLocal = default; + IReadOnlyList validTime = default; + Measures visibility = default; + Measures windDirection = default; + Measures windGust = default; + Measures windSpeed = default; + IReadOnlyList wxPhraseLong = default; + IReadOnlyList wxPhraseShort = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("additionalAttributes"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + Dictionary dictionary = new Dictionary(); + foreach (var property0 in property.Value.EnumerateObject()) + { + if (property0.Value.ValueKind == JsonValueKind.Null) + { + dictionary.Add(property0.Name, null); + } + else + { + dictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); + } + } + additionalAttributes = dictionary; + continue; + } + if (property.NameEquals("wetBulbTemperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + wetBulbTemperature = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("cloudCover"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + cloudCover = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("dayOfWeek"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dayOfWeek = array; + continue; + } + if (property.NameEquals("dayOrNight"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + dayOrNight = array; + continue; + } + if (property.NameEquals("expirationTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + expirationTime = array; + continue; + } + if (property.NameEquals("iconCode"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + iconCode = array; + continue; + } + if (property.NameEquals("iconCodeExtend"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetInt32()); + } + iconCodeExtend = array; + continue; + } + if (property.NameEquals("hasPrecipitation"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetBoolean()); + } + hasPrecipitation = array; + continue; + } + if (property.NameEquals("pressureMeanSeaLevel"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + pressureMeanSeaLevel = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("relativeHumidity"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + relativeHumidity = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("temperature"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + temperature = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("temperatureDewPoint"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + temperatureDewPoint = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("temperatureFeelsLike"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + temperatureFeelsLike = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("temperatureHeatIndex"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + temperatureHeatIndex = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("temperatureWindChill"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + temperatureWindChill = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("uvDescription"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + uvDescription = array; + continue; + } + if (property.NameEquals("uvIndex"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetDouble()); + } + uvIndex = array; + continue; + } + if (property.NameEquals("validTimeLocal"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + validTimeLocal = array; + continue; + } + if (property.NameEquals("validTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + validTime = array; + continue; + } + if (property.NameEquals("visibility"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + visibility = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("windDirection"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + windDirection = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("windGust"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + windGust = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("windSpeed"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + windSpeed = Measures.DeserializeMeasures(property.Value, options); + continue; + } + if (property.NameEquals("wxPhraseLong"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + wxPhraseLong = array; + continue; + } + if (property.NameEquals("wxPhraseShort"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(item.GetString()); + } + wxPhraseShort = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WeatherData( + additionalAttributes ?? new ChangeTrackingDictionary(), + wetBulbTemperature, + cloudCover, + dayOfWeek ?? new ChangeTrackingList(), + dayOrNight ?? new ChangeTrackingList(), + expirationTime ?? new ChangeTrackingList(), + iconCode ?? new ChangeTrackingList(), + iconCodeExtend ?? new ChangeTrackingList(), + hasPrecipitation ?? new ChangeTrackingList(), + pressureMeanSeaLevel, + relativeHumidity, + temperature, + temperatureDewPoint, + temperatureFeelsLike, + temperatureHeatIndex, + temperatureWindChill, + uvDescription ?? new ChangeTrackingList(), + uvIndex ?? new ChangeTrackingList(), + validTimeLocal ?? new ChangeTrackingList(), + validTime ?? new ChangeTrackingList(), + visibility, + windDirection, + windGust, + windSpeed, + wxPhraseLong ?? new ChangeTrackingList(), + wxPhraseShort ?? new ChangeTrackingList(), + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WeatherData)} does not support writing '{options.Format}' format."); + } + } + + WeatherData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeatherData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static WeatherData FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherData(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherData.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherData.cs new file mode 100644 index 000000000000..f36423d66d93 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherData.cs @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema of weather data. + public partial class WeatherData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal WeatherData() + { + AdditionalAttributes = new ChangeTrackingDictionary(); + DayOfWeek = new ChangeTrackingList(); + DayOrNight = new ChangeTrackingList(); + ExpirationTime = new ChangeTrackingList(); + IconCode = new ChangeTrackingList(); + IconCodeExtend = new ChangeTrackingList(); + HasPrecipitation = new ChangeTrackingList(); + UvDescription = new ChangeTrackingList(); + UvIndex = new ChangeTrackingList(); + ValidTimeLocal = new ChangeTrackingList(); + ValidTime = new ChangeTrackingList(); + WxPhraseLong = new ChangeTrackingList(); + WxPhraseShort = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// + /// 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 100 key value pairs can be provided for + /// a resource and only string and numeral values are supported. + /// + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Day of week. + /// + /// This data field indicates whether it is daytime or nighttime based on the Local + /// Apparent Time of the location. + /// + /// Expiration time in Utc format. + /// + /// This number is the key to the weather icon lookup. The data field shows the + /// icon number that is matched to represent the observed weather conditions. + /// + /// Code representing full set sensible weather. + /// Indicates whether there is precipitation or not. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// + /// The UV Index Description which complements the UV Index value by providing an + /// associated level of risk of skin damage due to exposure (-2 = Not Available, -1 + /// = No Report, 0 to 2 = Low, 3 to 5 = Moderate, 6 to 7 = High, 8 to 10 = Very + /// High, 11 to 16 = Extreme). + /// + /// Hourly maximum UV index. + /// Time forecast is valid in local apparent time. + /// Time forecast is valid in Utc format. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Schema for storing measurement readings and unit. + /// Hourly sensible weather phrase containing longer description. + /// Hourly sensible weather phrase containing short description. + /// Keeps track of any properties unknown to the library. + internal WeatherData(IReadOnlyDictionary additionalAttributes, Measures wetBulbTemperature, Measures cloudCover, IReadOnlyList dayOfWeek, IReadOnlyList dayOrNight, IReadOnlyList expirationTime, IReadOnlyList iconCode, IReadOnlyList iconCodeExtend, IReadOnlyList hasPrecipitation, Measures pressureMeanSeaLevel, Measures relativeHumidity, Measures temperature, Measures temperatureDewPoint, Measures temperatureFeelsLike, Measures temperatureHeatIndex, Measures temperatureWindChill, IReadOnlyList uvDescription, IReadOnlyList uvIndex, IReadOnlyList validTimeLocal, IReadOnlyList validTime, Measures visibility, Measures windDirection, Measures windGust, Measures windSpeed, IReadOnlyList wxPhraseLong, IReadOnlyList wxPhraseShort, IDictionary serializedAdditionalRawData) + { + AdditionalAttributes = additionalAttributes; + WetBulbTemperature = wetBulbTemperature; + CloudCover = cloudCover; + DayOfWeek = dayOfWeek; + DayOrNight = dayOrNight; + ExpirationTime = expirationTime; + IconCode = iconCode; + IconCodeExtend = iconCodeExtend; + HasPrecipitation = hasPrecipitation; + PressureMeanSeaLevel = pressureMeanSeaLevel; + RelativeHumidity = relativeHumidity; + Temperature = temperature; + TemperatureDewPoint = temperatureDewPoint; + TemperatureFeelsLike = temperatureFeelsLike; + TemperatureHeatIndex = temperatureHeatIndex; + TemperatureWindChill = temperatureWindChill; + UvDescription = uvDescription; + UvIndex = uvIndex; + ValidTimeLocal = validTimeLocal; + ValidTime = validTime; + Visibility = visibility; + WindDirection = windDirection; + WindGust = windGust; + WindSpeed = windSpeed; + WxPhraseLong = wxPhraseLong; + WxPhraseShort = wxPhraseShort; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// + /// 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 100 key value pairs can be provided for + /// a resource and only string and numeral values are supported. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + public IReadOnlyDictionary AdditionalAttributes { get; } + /// Schema for storing measurement readings and unit. + public Measures WetBulbTemperature { get; } + /// Schema for storing measurement readings and unit. + public Measures CloudCover { get; } + /// Day of week. + public IReadOnlyList DayOfWeek { get; } + /// + /// This data field indicates whether it is daytime or nighttime based on the Local + /// Apparent Time of the location. + /// + public IReadOnlyList DayOrNight { get; } + /// Expiration time in Utc format. + public IReadOnlyList ExpirationTime { get; } + /// + /// This number is the key to the weather icon lookup. The data field shows the + /// icon number that is matched to represent the observed weather conditions. + /// + public IReadOnlyList IconCode { get; } + /// Code representing full set sensible weather. + public IReadOnlyList IconCodeExtend { get; } + /// Indicates whether there is precipitation or not. + public IReadOnlyList HasPrecipitation { get; } + /// Schema for storing measurement readings and unit. + public Measures PressureMeanSeaLevel { get; } + /// Schema for storing measurement readings and unit. + public Measures RelativeHumidity { get; } + /// Schema for storing measurement readings and unit. + public Measures Temperature { get; } + /// Schema for storing measurement readings and unit. + public Measures TemperatureDewPoint { get; } + /// Schema for storing measurement readings and unit. + public Measures TemperatureFeelsLike { get; } + /// Schema for storing measurement readings and unit. + public Measures TemperatureHeatIndex { get; } + /// Schema for storing measurement readings and unit. + public Measures TemperatureWindChill { get; } + /// + /// The UV Index Description which complements the UV Index value by providing an + /// associated level of risk of skin damage due to exposure (-2 = Not Available, -1 + /// = No Report, 0 to 2 = Low, 3 to 5 = Moderate, 6 to 7 = High, 8 to 10 = Very + /// High, 11 to 16 = Extreme). + /// + public IReadOnlyList UvDescription { get; } + /// Hourly maximum UV index. + public IReadOnlyList UvIndex { get; } + /// Time forecast is valid in local apparent time. + public IReadOnlyList ValidTimeLocal { get; } + /// Time forecast is valid in Utc format. + public IReadOnlyList ValidTime { get; } + /// Schema for storing measurement readings and unit. + public Measures Visibility { get; } + /// Schema for storing measurement readings and unit. + public Measures WindDirection { get; } + /// Schema for storing measurement readings and unit. + public Measures WindGust { get; } + /// Schema for storing measurement readings and unit. + public Measures WindSpeed { get; } + /// Hourly sensible weather phrase containing longer description. + public IReadOnlyList WxPhraseLong { get; } + /// Hourly sensible weather phrase containing short description. + public IReadOnlyList WxPhraseShort { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherDataErrors.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherDataErrors.Serialization.cs new file mode 100644 index 000000000000..2fa4b8ab1818 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherDataErrors.Serialization.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class WeatherDataErrors : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherDataErrors)} does not support writing '{format}' format."); + } + + if (Optional.IsCollectionDefined(Locations)) + { + writer.WritePropertyName("locations"u8); + writer.WriteStartArray(); + foreach (var item in Locations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WeatherDataErrors IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherDataErrors)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeatherDataErrors(document.RootElement, options); + } + + internal static WeatherDataErrors DeserializeWeatherDataErrors(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + IReadOnlyList locations = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("locations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(ErrorForLocation.DeserializeErrorForLocation(item, options)); + } + locations = array; + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WeatherDataErrors(locations ?? new ChangeTrackingList(), serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WeatherDataErrors)} does not support writing '{options.Format}' format."); + } + } + + WeatherDataErrors IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherDataErrors(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeatherDataErrors)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static WeatherDataErrors FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherDataErrors(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherDataErrors.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherDataErrors.cs new file mode 100644 index 000000000000..1d56560133a9 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherDataErrors.cs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Model for errors encountered for all failed locations. + public partial class WeatherDataErrors + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal WeatherDataErrors() + { + Locations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// List of errors encountered for all failed locations. + /// Keeps track of any properties unknown to the library. + internal WeatherDataErrors(IReadOnlyList locations, IDictionary serializedAdditionalRawData) + { + Locations = locations; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// List of errors encountered for all failed locations. + public IReadOnlyList Locations { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocation.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocation.Serialization.cs new file mode 100644 index 000000000000..f13b81509597 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocation.Serialization.cs @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class WeatherLocation : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherLocation)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("type"u8); + writer.WriteStringValue(Type); + writer.WritePropertyName("value"u8); + writer.WriteStringValue(Value); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WeatherLocation IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherLocation)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeatherLocation(document.RootElement, options); + } + + internal static WeatherLocation DeserializeWeatherLocation(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string type = default; + string value = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WeatherLocation(type, value, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WeatherLocation)} does not support writing '{options.Format}' format."); + } + } + + WeatherLocation IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherLocation(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeatherLocation)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static WeatherLocation FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherLocation(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocation.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocation.cs new file mode 100644 index 000000000000..ea50a6ee8b02 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocation.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema of Location data. + public partial class WeatherLocation + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Location Type eg. LatLong/IataCode/IcaoCode/Placeid/PostalKey. + /// Location Value eg. "10,-25" for LocationType Type "LatLong". + /// or is null. + public WeatherLocation(string type, string value) + { + Argument.AssertNotNull(type, nameof(type)); + Argument.AssertNotNull(value, nameof(value)); + + Type = type; + Value = value; + } + + /// Initializes a new instance of . + /// Location Type eg. LatLong/IataCode/IcaoCode/Placeid/PostalKey. + /// Location Value eg. "10,-25" for LocationType Type "LatLong". + /// Keeps track of any properties unknown to the library. + internal WeatherLocation(string type, string value, IDictionary serializedAdditionalRawData) + { + Type = type; + Value = value; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WeatherLocation() + { + } + + /// Location Type eg. LatLong/IataCode/IcaoCode/Placeid/PostalKey. + public string Type { get; set; } + /// Location Value eg. "10,-25" for LocationType Type "LatLong". + public string Value { get; set; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocationData.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocationData.Serialization.cs new file mode 100644 index 000000000000..58cd8a07fe42 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocationData.Serialization.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class WeatherLocationData : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherLocationData)} does not support writing '{format}' format."); + } + + if (Optional.IsDefined(Location)) + { + writer.WritePropertyName("location"u8); + writer.WriteObjectValue(Location, options); + } + if (Optional.IsDefined(RequestCompletionTime)) + { + writer.WritePropertyName("requestCompletionTime"u8); + writer.WriteStringValue(RequestCompletionTime); + } + if (Optional.IsDefined(LastRefreshedDateTime)) + { + writer.WritePropertyName("lastRefreshedDateTime"u8); + writer.WriteStringValue(LastRefreshedDateTime.Value, "O"); + } + if (Optional.IsDefined(Data)) + { + writer.WritePropertyName("data"u8); + writer.WriteObjectValue(Data, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WeatherLocationData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherLocationData)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeatherLocationData(document.RootElement, options); + } + + internal static WeatherLocationData DeserializeWeatherLocationData(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WeatherLocation location = default; + string requestCompletionTime = default; + DateTimeOffset? lastRefreshedDateTime = default; + WeatherData data = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("location"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + location = WeatherLocation.DeserializeWeatherLocation(property.Value, options); + continue; + } + if (property.NameEquals("requestCompletionTime"u8)) + { + requestCompletionTime = property.Value.GetString(); + continue; + } + if (property.NameEquals("lastRefreshedDateTime"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + lastRefreshedDateTime = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + data = WeatherData.DeserializeWeatherData(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WeatherLocationData(location, requestCompletionTime, lastRefreshedDateTime, data, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WeatherLocationData)} does not support writing '{options.Format}' format."); + } + } + + WeatherLocationData IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherLocationData(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeatherLocationData)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static WeatherLocationData FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherLocationData(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocationData.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocationData.cs new file mode 100644 index 000000000000..95d1cecb1cec --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherLocationData.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema of WeatherLocationData data. + public partial class WeatherLocationData + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + internal WeatherLocationData() + { + } + + /// Initializes a new instance of . + /// Schema of Location data. + /// Request Completion Time in Utc of the location. + /// Date-time when resource was last requested, sample format: yyyy-MM-ddTHH:mm:ssZ. + /// Schema of weather data. + /// Keeps track of any properties unknown to the library. + internal WeatherLocationData(WeatherLocation location, string requestCompletionTime, DateTimeOffset? lastRefreshedDateTime, WeatherData data, IDictionary serializedAdditionalRawData) + { + Location = location; + RequestCompletionTime = requestCompletionTime; + LastRefreshedDateTime = lastRefreshedDateTime; + Data = data; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Schema of Location data. + public WeatherLocation Location { get; } + /// Request Completion Time in Utc of the location. + public string RequestCompletionTime { get; } + /// Date-time when resource was last requested, sample format: yyyy-MM-ddTHH:mm:ssZ. + public DateTimeOffset? LastRefreshedDateTime { get; } + /// Schema of weather data. + public WeatherData Data { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherMetadata.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherMetadata.Serialization.cs new file mode 100644 index 000000000000..f2a60dfe6302 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherMetadata.Serialization.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class WeatherMetadata : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherMetadata)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("providerName"u8); + writer.WriteStringValue(ProviderName); + writer.WritePropertyName("providerApiName"u8); + writer.WriteStringValue(ProviderApiName); + if (Optional.IsDefined(Language)) + { + writer.WritePropertyName("language"u8); + writer.WriteStringValue(Language); + } + writer.WritePropertyName("units"u8); + writer.WriteStringValue(Units); + writer.WritePropertyName("weatherDataType"u8); + writer.WriteStringValue(WeatherDataType); + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WeatherMetadata IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherMetadata)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeatherMetadata(document.RootElement, options); + } + + internal static WeatherMetadata DeserializeWeatherMetadata(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string providerName = default; + string providerApiName = default; + string language = default; + string units = default; + string weatherDataType = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("providerName"u8)) + { + providerName = property.Value.GetString(); + continue; + } + if (property.NameEquals("providerApiName"u8)) + { + providerApiName = property.Value.GetString(); + continue; + } + if (property.NameEquals("language"u8)) + { + language = property.Value.GetString(); + continue; + } + if (property.NameEquals("units"u8)) + { + units = property.Value.GetString(); + continue; + } + if (property.NameEquals("weatherDataType"u8)) + { + weatherDataType = property.Value.GetString(); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WeatherMetadata( + providerName, + providerApiName, + language, + units, + weatherDataType, + serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WeatherMetadata)} does not support writing '{options.Format}' format."); + } + } + + WeatherMetadata IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherMetadata(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeatherMetadata)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static WeatherMetadata FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherMetadata(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherMetadata.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherMetadata.cs new file mode 100644 index 000000000000..077b20635555 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherMetadata.cs @@ -0,0 +1,118 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema of Weather Metadata. + public partial class WeatherMetadata + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Weather provider name. + /// Provider's api name to which request is to be made. + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + /// Type of weather data (forecast/historical). + /// , , or is null. + internal WeatherMetadata(string providerName, string providerApiName, string units, string weatherDataType) + { + Argument.AssertNotNull(providerName, nameof(providerName)); + Argument.AssertNotNull(providerApiName, nameof(providerApiName)); + Argument.AssertNotNull(units, nameof(units)); + Argument.AssertNotNull(weatherDataType, nameof(weatherDataType)); + + ProviderName = providerName; + ProviderApiName = providerApiName; + Units = units; + WeatherDataType = weatherDataType; + } + + /// Initializes a new instance of . + /// Weather provider name. + /// Provider's api name to which request is to be made. + /// + /// Language (IETF BCP 47 language tag) in which search results should be returned + /// by the data provider. Examples: 'en-US', 'es', 'es-MX', 'fr-FR'. + /// + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + /// Type of weather data (forecast/historical). + /// Keeps track of any properties unknown to the library. + internal WeatherMetadata(string providerName, string providerApiName, string language, string units, string weatherDataType, IDictionary serializedAdditionalRawData) + { + ProviderName = providerName; + ProviderApiName = providerApiName; + Language = language; + Units = units; + WeatherDataType = weatherDataType; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WeatherMetadata() + { + } + + /// Weather provider name. + public string ProviderName { get; } + /// Provider's api name to which request is to be made. + public string ProviderApiName { get; } + /// + /// Language (IETF BCP 47 language tag) in which search results should be returned + /// by the data provider. Examples: 'en-US', 'es', 'es-MX', 'fr-FR'. + /// + public string Language { get; } + /// + /// Units for which request to data provider is to be sent. Supported values are + /// 'e' for English units, 'm' for Metric units, 'h' for Hybrid units (UK) and 's' + /// for Metric SI units. + /// + public string Units { get; } + /// Type of weather data (forecast/historical). + public string WeatherDataType { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherResponse.Serialization.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherResponse.Serialization.cs new file mode 100644 index 000000000000..617a324f6d57 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherResponse.Serialization.cs @@ -0,0 +1,193 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.AgriculturePlatform +{ + public partial class WeatherResponse : IUtf8JsonSerializable, IJsonModel + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); + + void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherResponse)} does not support writing '{format}' format."); + } + + writer.WritePropertyName("weatherMetadata"u8); + writer.WriteObjectValue(WeatherMetadata, options); + if (Optional.IsDefined(Status)) + { + writer.WritePropertyName("status"u8); + writer.WriteStringValue(Status); + } + if (Optional.IsCollectionDefined(Locations)) + { + writer.WritePropertyName("locations"u8); + writer.WriteStartArray(); + foreach (var item in Locations) + { + writer.WriteObjectValue(item, options); + } + writer.WriteEndArray(); + } + if (Optional.IsDefined(Errors)) + { + writer.WritePropertyName("errors"u8); + writer.WriteObjectValue(Errors, options); + } + if (options.Format != "W" && _serializedAdditionalRawData != null) + { + foreach (var item in _serializedAdditionalRawData) + { + writer.WritePropertyName(item.Key); +#if NET6_0_OR_GREATER + writer.WriteRawValue(item.Value); +#else + using (JsonDocument document = JsonDocument.Parse(item.Value, ModelSerializationExtensions.JsonDocumentOptions)) + { + JsonSerializer.Serialize(writer, document.RootElement); + } +#endif + } + } + } + + WeatherResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + if (format != "J") + { + throw new FormatException($"The model {nameof(WeatherResponse)} does not support reading '{format}' format."); + } + + using JsonDocument document = JsonDocument.ParseValue(ref reader); + return DeserializeWeatherResponse(document.RootElement, options); + } + + internal static WeatherResponse DeserializeWeatherResponse(JsonElement element, ModelReaderWriterOptions options = null) + { + options ??= ModelSerializationExtensions.WireOptions; + + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + WeatherMetadata weatherMetadata = default; + string status = default; + IReadOnlyList locations = default; + WeatherDataErrors errors = default; + IDictionary serializedAdditionalRawData = default; + Dictionary rawDataDictionary = new Dictionary(); + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("weatherMetadata"u8)) + { + weatherMetadata = WeatherMetadata.DeserializeWeatherMetadata(property.Value, options); + continue; + } + if (property.NameEquals("status"u8)) + { + status = property.Value.GetString(); + continue; + } + if (property.NameEquals("locations"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(WeatherLocationData.DeserializeWeatherLocationData(item, options)); + } + locations = array; + continue; + } + if (property.NameEquals("errors"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + errors = WeatherDataErrors.DeserializeWeatherDataErrors(property.Value, options); + continue; + } + if (options.Format != "W") + { + rawDataDictionary.Add(property.Name, BinaryData.FromString(property.Value.GetRawText())); + } + } + serializedAdditionalRawData = rawDataDictionary; + return new WeatherResponse(weatherMetadata, status, locations ?? new ChangeTrackingList(), errors, serializedAdditionalRawData); + } + + BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + return ModelReaderWriter.Write(this, options); + default: + throw new FormatException($"The model {nameof(WeatherResponse)} does not support writing '{options.Format}' format."); + } + } + + WeatherResponse IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) + { + var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; + + switch (format) + { + case "J": + { + using JsonDocument document = JsonDocument.Parse(data, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherResponse(document.RootElement, options); + } + default: + throw new FormatException($"The model {nameof(WeatherResponse)} does not support reading '{options.Format}' format."); + } + } + + string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; + + /// Deserializes the model from a raw response. + /// The response to deserialize the model from. + internal static WeatherResponse FromResponse(Response response) + { + using var document = JsonDocument.Parse(response.Content, ModelSerializationExtensions.JsonDocumentOptions); + return DeserializeWeatherResponse(document.RootElement); + } + + /// Convert into a . + internal virtual RequestContent ToRequestContent() + { + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); + return content; + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherResponse.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherResponse.cs new file mode 100644 index 000000000000..aaaf64cf5a9b --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Generated/WeatherResponse.cs @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; + +namespace Azure.AgriculturePlatform +{ + /// Schema of Weather Data Provider Response. + public partial class WeatherResponse + { + /// + /// Keeps track of any properties unknown to the library. + /// + /// To assign an object to the value of this property use . + /// + /// + /// To assign an already formatted json string to this property use . + /// + /// + /// Examples: + /// + /// + /// BinaryData.FromObjectAsJson("foo") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromString("\"foo\"") + /// Creates a payload of "foo". + /// + /// + /// BinaryData.FromObjectAsJson(new { key = "value" }) + /// Creates a payload of { "key": "value" }. + /// + /// + /// BinaryData.FromString("{\"key\": \"value\"}") + /// Creates a payload of { "key": "value" }. + /// + /// + /// + /// + private IDictionary _serializedAdditionalRawData; + + /// Initializes a new instance of . + /// Schema of Weather Metadata. + /// is null. + internal WeatherResponse(WeatherMetadata weatherMetadata) + { + Argument.AssertNotNull(weatherMetadata, nameof(weatherMetadata)); + + WeatherMetadata = weatherMetadata; + Locations = new ChangeTrackingList(); + } + + /// Initializes a new instance of . + /// Schema of Weather Metadata. + /// Indicates a Succeeded, Failed, or PartiallySucceeded response. + /// List of weather data for all the weather locations. + /// Model for errors encountered for all failed locations. + /// Keeps track of any properties unknown to the library. + internal WeatherResponse(WeatherMetadata weatherMetadata, string status, IReadOnlyList locations, WeatherDataErrors errors, IDictionary serializedAdditionalRawData) + { + WeatherMetadata = weatherMetadata; + Status = status; + Locations = locations; + Errors = errors; + _serializedAdditionalRawData = serializedAdditionalRawData; + } + + /// Initializes a new instance of for deserialization. + internal WeatherResponse() + { + } + + /// Schema of Weather Metadata. + public WeatherMetadata WeatherMetadata { get; } + /// Indicates a Succeeded, Failed, or PartiallySucceeded response. + public string Status { get; } + /// List of weather data for all the weather locations. + public IReadOnlyList Locations { get; } + /// Model for errors encountered for all failed locations. + public WeatherDataErrors Errors { get; } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Properties/AssemblyInfo.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..93cb1210b211 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/src/Properties/AssemblyInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Azure.AgriculturePlatform.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")] diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Azure.AgriculturePlatform.Tests.csproj b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Azure.AgriculturePlatform.Tests.csproj new file mode 100644 index 000000000000..b39bde7a7573 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Azure.AgriculturePlatform.Tests.csproj @@ -0,0 +1,20 @@ + + + $(RequiredTargetFrameworks) + + $(NoWarn);CS1591 + + + + + + + + + + + + + + + diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Catalogs.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Catalogs.cs new file mode 100644 index 000000000000..15b6375674c5 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Catalogs.cs @@ -0,0 +1,222 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_Catalogs + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Catalog_GetCatalog_CatalogsGet() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetCatalog("CATALOG123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Catalog_GetCatalog_CatalogsGet_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetCatalogAsync("CATALOG123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Catalog_GetCatalog_CatalogsGet_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetCatalog("CATALOG123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Catalog_GetCatalog_CatalogsGet_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetCatalogAsync("CATALOG123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Catalog_CreateOrUpdate_CatalogsCreateOrUpdate() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = client.CreateOrUpdate("CATALOG123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Catalog_CreateOrUpdate_CatalogsCreateOrUpdate_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = await client.CreateOrUpdateAsync("CATALOG123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Catalog_Delete_CatalogsDelete() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Delete("CATALOG123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Catalog_Delete_CatalogsDelete_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.DeleteAsync("CATALOG123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Catalog_GetCatalogs_CatalogsList() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + foreach (BinaryData item in client.GetCatalogs(null, null, null, null, null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Catalog_GetCatalogs_CatalogsList_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + await foreach (BinaryData item in client.GetCatalogsAsync(null, null, null, null, null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Catalog_GetCatalogs_CatalogsList_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + foreach (Catalog item in client.GetCatalogs()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Catalog_GetCatalogs_CatalogsList_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Catalogs client = new AgriculturePlatformClient(endpoint, credential).GetCatalogsClient(apiVersion: "2024-11-01-preview"); + + await foreach (Catalog item in client.GetCatalogsAsync()) + { + } + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Collections.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Collections.cs new file mode 100644 index 000000000000..dbcdfc2b88b7 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Collections.cs @@ -0,0 +1,230 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_Collections + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Collection_GetCollection_CollectionsGet() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetCollection("CATALOG123", "COLLECTION123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Collection_GetCollection_CollectionsGet_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetCollectionAsync("CATALOG123", "COLLECTION123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Collection_GetCollection_CollectionsGet_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetCollection("CATALOG123", "COLLECTION123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Collection_GetCollection_CollectionsGet_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetCollectionAsync("CATALOG123", "COLLECTION123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Collection_CreateOrUpdate_CollectionsCreateOrUpdate() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + schemaId = "SCHEMA123", + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = client.CreateOrUpdate("CATALOG123", "COLLECTION123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Collection_CreateOrUpdate_CollectionsCreateOrUpdate_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + schemaId = "SCHEMA123", + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = await client.CreateOrUpdateAsync("CATALOG123", "COLLECTION123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Collection_Delete_CollectionsDelete() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Delete("CATALOG123", "COLLECTION123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Collection_Delete_CollectionsDelete_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.DeleteAsync("CATALOG123", "COLLECTION123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Collection_GetCollections_CollectionsList() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + foreach (BinaryData item in client.GetCollections("CATALOG123", null, null, null, null, null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Collection_GetCollections_CollectionsList_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + await foreach (BinaryData item in client.GetCollectionsAsync("CATALOG123", null, null, null, null, null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaId").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Collection_GetCollections_CollectionsList_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + foreach (Collection item in client.GetCollections("CATALOG123")) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Collection_GetCollections_CollectionsList_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Collections client = new AgriculturePlatformClient(endpoint, credential).GetCollectionsClient(apiVersion: "2024-11-01-preview"); + + await foreach (Collection item in client.GetCollectionsAsync("CATALOG123")) + { + } + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_File.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_File.cs new file mode 100644 index 000000000000..a10919432e48 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_File.cs @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_File + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FileOperations_Delete_FileDelete() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + filePath = "string", + }); + Response response = client.Delete(content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FileOperations_Delete_FileDelete_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + filePath = "string", + }); + Response response = await client.DeleteAsync(content); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FileOperations_Delete_FileDelete_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Delete("string"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FileOperations_Delete_FileDelete_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.DeleteAsync("string"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FileOperations_Download_FileDownload() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + filePath = "string", + }); + Response response = client.Download("application/json", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FileOperations_Download_FileDownload_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + filePath = "string", + }); + Response response = await client.DownloadAsync("application/json", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FileOperations_Download_FileDownload_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Download(AcceptHeaderEnum.Json, "string"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FileOperations_Download_FileDownload_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.DownloadAsync(AcceptHeaderEnum.Json, "string"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FileOperations_Upload_FileUpload() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Upload(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("filePath").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FileOperations_Upload_FileUpload_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.UploadAsync(null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("filePath").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_FileOperations_Upload_FileUpload_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Upload(); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_FileOperations_Upload_FileUpload_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + File client = new AgriculturePlatformClient(endpoint, credential).GetFileClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.UploadAsync(); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Items.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Items.cs new file mode 100644 index 000000000000..dda95149551b --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Items.cs @@ -0,0 +1,440 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_Items + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ItemsOperations_Create_ItemsCreate() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + data = new + { + additionalProp1 = "string", + additionalProp2 = "string", + additionalProp3 = "string", + }, + assets = new object[] + { +new +{ +type = "Image", +name = "string", +href = "string", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = client.Create("CATALOG123", "COLLECTION123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ItemsOperations_Create_ItemsCreate_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + data = new + { + additionalProp1 = "string", + additionalProp2 = "string", + additionalProp3 = "string", + }, + assets = new object[] + { +new +{ +type = "Image", +name = "string", +href = "string", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = await client.CreateAsync("CATALOG123", "COLLECTION123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ItemsOperations_Create_ItemsCreate_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Create("CATALOG123", "COLLECTION123", new Dictionary + { + ["additionalProp1"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp2"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp3"] = BinaryData.FromObjectAsJson("string") + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ItemsOperations_Create_ItemsCreate_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.CreateAsync("CATALOG123", "COLLECTION123", new Dictionary + { + ["additionalProp1"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp2"] = BinaryData.FromObjectAsJson("string"), + ["additionalProp3"] = BinaryData.FromObjectAsJson("string") + }); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Item_GetItem_ItemsGet() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetItem("CATALOG123", "COLLECTION123", "ITEM123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Item_GetItem_ItemsGet_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetItemAsync("CATALOG123", "COLLECTION123", "ITEM123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Item_GetItem_ItemsGet_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetItem("CATALOG123", "COLLECTION123", "ITEM123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Item_GetItem_ItemsGet_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetItemAsync("CATALOG123", "COLLECTION123", "ITEM123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Item_CreateOrUpdate_ItemsCreateOrUpdate() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + data = new + { + Company = "string", + name = "string", + }, + ownerItemId = "lavi-item", + assets = new object[] + { +new +{ +type = "Image", +name = "string", +href = "string", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = client.CreateOrUpdate("CATALOG123", "COLLECTION123", "ITEM123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Item_CreateOrUpdate_ItemsCreateOrUpdate_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + links = new object[] + { +new +{ +rel = "DerivedFrom", +href = "string", +type = "Catalog", +} + }, + data = new + { + Company = "string", + name = "string", + }, + ownerItemId = "lavi-item", + assets = new object[] + { +new +{ +type = "Image", +name = "string", +href = "string", +} + }, + status = "string", + source = "string", + name = "string", + description = "string", + properties = new + { + key1 = "value1", + key2 = 123.45F, + }, + }); + Response response = await client.CreateOrUpdateAsync("CATALOG123", "COLLECTION123", "ITEM123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Item_Delete_ItemsDelete() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Delete("CATALOG123", "COLLECTION123", "ITEM123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Item_Delete_ItemsDelete_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.DeleteAsync("CATALOG123", "COLLECTION123", "ITEM123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ItemsOperations_GetAllUnderCollection_ItemsGetAllUnderCollection() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new object()); + Response response = client.GetAllUnderCollection("CATALOG123", "COLLECTION123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ItemsOperations_GetAllUnderCollection_ItemsGetAllUnderCollection_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new object()); + Response response = await client.GetAllUnderCollectionAsync("CATALOG123", "COLLECTION123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ItemsOperations_GetAllUnderCollection_ItemsGetAllUnderCollection_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetAllUnderCollection("CATALOG123", "COLLECTION123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ItemsOperations_GetAllUnderCollection_ItemsGetAllUnderCollection_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetAllUnderCollectionAsync("CATALOG123", "COLLECTION123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ItemsOperations_SearchAcrossCollection_ItemsSearchAcrossCollection() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new object()); + Response response = client.SearchAcrossCollection("CATALOG123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ItemsOperations_SearchAcrossCollection_ItemsSearchAcrossCollection_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new object()); + Response response = await client.SearchAcrossCollectionAsync("CATALOG123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("value")[0].GetProperty("data").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("value")[0].GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_ItemsOperations_SearchAcrossCollection_ItemsSearchAcrossCollection_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.SearchAcrossCollection("CATALOG123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_ItemsOperations_SearchAcrossCollection_ItemsSearchAcrossCollection_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Items client = new AgriculturePlatformClient(endpoint, credential).GetItemsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.SearchAcrossCollectionAsync("CATALOG123"); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Satellite.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Satellite.cs new file mode 100644 index 000000000000..4103c6958063 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Satellite.cs @@ -0,0 +1,347 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_Satellite + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SatelliteOperations_FetchItems_SatelliteFetchItems() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + startDateTime = "2024-06-05T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-14T12:42:29.217Z", + provider = "SentinelHub", + itemUri = "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", + data = new + { + imageNames = new object[] + { +"NDVI", +"B04", +"B08", +"dataMask", +"CLM" + }, + imageFormats = new object[] + { +"TIF" + }, + imageResolutions = new object[] + { +10 + }, + }, + providerCollectionId = "sentinel-2-l2a", + }); + Response response = client.FetchItems(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SatelliteOperations_FetchItems_SatelliteFetchItems_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + startDateTime = "2024-06-05T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-14T12:42:29.217Z", + provider = "SentinelHub", + itemUri = "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", + data = new + { + imageNames = new object[] + { +"NDVI", +"B04", +"B08", +"dataMask", +"CLM" + }, + imageFormats = new object[] + { +"TIF" + }, + imageResolutions = new object[] + { +10 + }, + }, + providerCollectionId = "sentinel-2-l2a", + }); + Response response = await client.FetchItemsAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SatelliteOperations_FetchItems_SatelliteFetchItems_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); + SatelliteData data = new SatelliteData + { + ImageNames = { "NDVI", "B04", "B08", "dataMask", "CLM" }, + ImageFormats = { "TIF" }, + ImageResolutions = { 10 }, + }; + Response response = client.FetchItems(credentials, "SentinelHub", "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", data, "sentinel-2-l2a"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SatelliteOperations_FetchItems_SatelliteFetchItems_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); + SatelliteData data = new SatelliteData + { + ImageNames = { "NDVI", "B04", "B08", "dataMask", "CLM" }, + ImageFormats = { "TIF" }, + ImageResolutions = { 10 }, + }; + Response response = await client.FetchItemsAsync(credentials, "SentinelHub", "/catalogs/CATALOG123/collections/utka-collection/items/utka-item", data, "sentinel-2-l2a"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SatelliteOperations_SearchItems_SatelliteSearchItems() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + startDateTime = "2024-06-15T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-22T12:42:29.217Z", + intersects = new + { + type = "Polygon", + coordinates = new object[] + { +new object[] +{ +new object[] +{ +73.70457172393799, +20.545385304358106 +}, +new object[] +{ +73.70457172393799, +20.545385304358106 +}, +new object[] +{ +73.70448589324951, +20.542411534243367 +}, +new object[] +{ +73.70877742767334, +20.541688176010233 +}, +new object[] +{ +73.71023654937744, +20.545083911372505 +}, +new object[] +{ +73.70663166046143, +20.546992723579137 +}, +new object[] +{ +73.70457172393799, +20.545385304358106 +} +} + }, + }, + providerCollectionId = "sentinel-2-l2a", + provider = "SentinelHub", + }); + Response response = client.SearchItems(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SatelliteOperations_SearchItems_SatelliteSearchItems_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + startDateTime = "2024-06-15T12:42:29.217Z", + credentials = new + { + kind = "OAuthClientCredentials", + clientId = "ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", + clientSecret = new + { + keyVaultUri = "https://bhkankv.vault.azure.net", + keyName = "SentinelHubClientSecret", + keyVersion = "8fa2ce7e42df4b65991f818298eb9435", + }, + }, + endDateTime = "2024-06-22T12:42:29.217Z", + intersects = new + { + type = "Polygon", + coordinates = new object[] + { +new object[] +{ +new object[] +{ +73.70457172393799, +20.545385304358106 +}, +new object[] +{ +73.70457172393799, +20.545385304358106 +}, +new object[] +{ +73.70448589324951, +20.542411534243367 +}, +new object[] +{ +73.70877742767334, +20.541688176010233 +}, +new object[] +{ +73.71023654937744, +20.545083911372505 +}, +new object[] +{ +73.70663166046143, +20.546992723579137 +}, +new object[] +{ +73.70457172393799, +20.545385304358106 +} +} + }, + }, + providerCollectionId = "sentinel-2-l2a", + provider = "SentinelHub", + }); + Response response = await client.SearchItemsAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].ToString()); + Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SatelliteOperations_SearchItems_SatelliteSearchItems_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); + Response response = client.SearchItems(credentials, "SentinelHub", "sentinel-2-l2a"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SatelliteOperations_SearchItems_SatelliteSearchItems_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Satellite client = new AgriculturePlatformClient(endpoint, credential).GetSatelliteClient(apiVersion: "2024-11-01-preview"); + + OauthClientCredentials credentials = new OauthClientCredentials("ed16ee3f-9742-42cc-a71b-dcd90c3b6c03", new KeyVaultProperties("https://bhkankv.vault.azure.net", "SentinelHubClientSecret", "8fa2ce7e42df4b65991f818298eb9435")); + Response response = await client.SearchItemsAsync(credentials, "SentinelHub", "sentinel-2-l2a"); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Schemas.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Schemas.cs new file mode 100644 index 000000000000..3e163e31e760 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Schemas.cs @@ -0,0 +1,232 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_Schemas + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Schema_GetSchema_SchemasGet() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetSchema("SCHEMA123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Schema_GetSchema_SchemasGet_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetSchemaAsync("SCHEMA123", null); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Schema_GetSchema_SchemasGet_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetSchema("SCHEMA123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Schema_GetSchema_SchemasGet_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetSchemaAsync("SCHEMA123"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Schema_CreateOrUpdate_SchemasCreateOrUpdate() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + schemaModel = new + { + type = "object", + properties = new Dictionary + { + ["$id"] = "3308", + ["name"] = new Dictionary + { + ["$id"] = "3309", + ["type"] = "string", + ["minLength"] = 2, + ["maxLength"] = 100 + }, + ["geometry"] = new Dictionary + { + ["$id"] = "3310", + ["type"] = "object" + } + }, + }, + }); + Response response = client.CreateOrUpdate("SCHEMA123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Schema_CreateOrUpdate_SchemasCreateOrUpdate_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + schemaModel = new + { + type = "object", + properties = new Dictionary + { + ["$id"] = "3308", + ["name"] = new Dictionary + { + ["$id"] = "3309", + ["type"] = "string", + ["minLength"] = 2, + ["maxLength"] = 100 + }, + ["geometry"] = new Dictionary + { + ["$id"] = "3310", + ["type"] = "object" + } + }, + }, + }); + Response response = await client.CreateOrUpdateAsync("SCHEMA123", content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Schema_Delete_SchemasDelete() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + Response response = client.Delete("SCHEMA123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Schema_Delete_SchemasDelete_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.DeleteAsync("SCHEMA123"); + + Console.WriteLine(response.Status); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Schema_GetSchemas_SchemasList() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + foreach (BinaryData item in client.GetSchemas(null, null, null, null, null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Schema_GetSchemas_SchemasList_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + await foreach (BinaryData item in client.GetSchemasAsync(null, null, null, null, null, null, null, null, null, null, null)) + { + JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement; + Console.WriteLine(result.GetProperty("schemaModel").GetProperty("").ToString()); + Console.WriteLine(result.GetProperty("id").ToString()); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_Schema_GetSchemas_SchemasList_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + foreach (Schema item in client.GetSchemas()) + { + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_Schema_GetSchemas_SchemasList_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Schemas client = new AgriculturePlatformClient(endpoint, credential).GetSchemasClient(apiVersion: "2024-11-01-preview"); + + await foreach (Schema item in client.GetSchemasAsync()) + { + } + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Solutions.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Solutions.cs new file mode 100644 index 000000000000..119f2ac1b0de --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Solutions.cs @@ -0,0 +1,280 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_Solutions + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_CancelJob_SolutionCancelJob() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = client.CancelJob(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_CancelJob_SolutionCancelJob_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = await client.CancelJobAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_CancelJob_SolutionCancelJob_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.CancelJob("string", "string", new Dictionary(), new Dictionary()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_CancelJob_SolutionCancelJob_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.CancelJobAsync("string", "string", new Dictionary(), new Dictionary()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_CreateJob_SolutionCreateJob() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = client.CreateJob(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_CreateJob_SolutionCreateJob_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = await client.CreateJobAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_CreateJob_SolutionCreateJob_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.CreateJob("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_CreateJob_SolutionCreateJob_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.CreateJobAsync("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_GetData_SolutionGetData() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = client.GetData(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_GetData_SolutionGetData_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + inputData = new object(), + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = await client.GetDataAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_GetData_SolutionGetData_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetData("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_GetData_SolutionGetData_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetDataAsync("string", "string", new Dictionary(), new Dictionary(), new Dictionary()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_GetJob_SolutionGetJob() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = client.GetJob(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_GetJob_SolutionGetJob_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + solutionId = "string", + requestPath = "string", + partnerRequestBody = new object(), + partnerRequestHeaders = new object(), + }); + Response response = await client.GetJobAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_SolutionsOperations_GetJob_SolutionGetJob_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetJob("string", "string", new Dictionary(), new Dictionary()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_SolutionsOperations_GetJob_SolutionGetJob_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Solutions client = new AgriculturePlatformClient(endpoint, credential).GetSolutionsClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetJobAsync("string", "string", new Dictionary(), new Dictionary()); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Weather.cs b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Weather.cs new file mode 100644 index 000000000000..61a3197770fa --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tests/Generated/Samples/Samples_Weather.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using NUnit.Framework; + +namespace Azure.AgriculturePlatform.Samples +{ + public partial class Samples_Weather + { + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_WeatherOperations_GetWeatherOperation_WeatherGet() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + credentials = new + { + apiKey = new + { + keyVaultUri = "string", + keyName = "string", + keyVersion = "string", + }, + }, + locations = new object[] + { +new +{ +type = "string", +value = "string", +} + }, + providerName = "string", + providerApiName = "string", + language = "en-US", + units = "string", + }); + Response response = client.GetWeatherOperation(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerName").ToString()); + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerApiName").ToString()); + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("units").ToString()); + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("weatherDataType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_WeatherOperations_GetWeatherOperation_WeatherGet_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + + using RequestContent content = RequestContent.Create(new + { + credentials = new + { + apiKey = new + { + keyVaultUri = "string", + keyName = "string", + keyVersion = "string", + }, + }, + locations = new object[] + { +new +{ +type = "string", +value = "string", +} + }, + providerName = "string", + providerApiName = "string", + language = "en-US", + units = "string", + }); + Response response = await client.GetWeatherOperationAsync(content); + + JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerName").ToString()); + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("providerApiName").ToString()); + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("units").ToString()); + Console.WriteLine(result.GetProperty("weatherMetadata").GetProperty("weatherDataType").ToString()); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public void Example_WeatherOperations_GetWeatherOperation_WeatherGet_Convenience() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + + Response response = client.GetWeatherOperation("string", "string", "string"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Example_WeatherOperations_GetWeatherOperation_WeatherGet_Convenience_Async() + { + Uri endpoint = new Uri(""); + AzureKeyCredential credential = new AzureKeyCredential(""); + Weather client = new AgriculturePlatformClient(endpoint, credential).GetWeatherClient(apiVersion: "2024-11-01-preview"); + + Response response = await client.GetWeatherOperationAsync("string", "string", "string"); + } + } +} diff --git a/sdk/agricultureplatform/Azure.AgriculturePlatform/tsp-location.yaml b/sdk/agricultureplatform/Azure.AgriculturePlatform/tsp-location.yaml new file mode 100644 index 000000000000..f96d93182101 --- /dev/null +++ b/sdk/agricultureplatform/Azure.AgriculturePlatform/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/agricultureplatform/AgriculturePlatform.DataPlane +commit: d2f1f08efff19f979c1c227dbc1a5a83649eba8d +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/agricultureplatform/ci.yml b/sdk/agricultureplatform/ci.yml new file mode 100644 index 000000000000..fa33f2d27366 --- /dev/null +++ b/sdk/agricultureplatform/ci.yml @@ -0,0 +1,35 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/agricultureplatform + - sdk/agricultureplatform/ci.yml + - sdk/agricultureplatform/Azure.AgriculturePlatform + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/agricultureplatform + - sdk/agricultureplatform/ci.yml + - sdk/agricultureplatform/Azure.AgriculturePlatform + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: agricultureplatform + ArtifactName: packages + Artifacts: + - name: Azure.AgriculturePlatform + safeName: AzureAgriculturePlatform