diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 3fe719778a20..a527ba930e75 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -285,6 +285,7 @@ com.azure.resourcemanager:azure-resourcemanager-labservices;1.0.0-beta.1;1.0.0-b com.azure.resourcemanager:azure-resourcemanager-vmwarecloudsimple;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-managedapplications;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-videoanalyzer;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-agfood;1.0.0-beta.1;1.0.0-beta.1 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current # version. Unreleased dependencies are only valid for dependency versions. diff --git a/pom.xml b/pom.xml index f3c7ab9c53b7..8279f5283503 100644 --- a/pom.xml +++ b/pom.xml @@ -668,6 +668,7 @@ eng/code-quality-reports eng/jacoco-test-coverage sdk/advisor + sdk/agfood sdk/anomalydetector sdk/apimanagement sdk/appconfiguration diff --git a/sdk/agfood/azure-resourcemanager-agfood/CHANGELOG.md b/sdk/agfood/azure-resourcemanager-agfood/CHANGELOG.md new file mode 100644 index 000000000000..83cd11347155 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-05-07) + +- Azure Resource Manager Agfood client library for Java. This package contains Microsoft Azure SDK for Agfood Management SDK. APIs documentation for Azure AgFoodPlatform Resource Provider Service. Package tag package-2020-05-12-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). diff --git a/sdk/agfood/azure-resourcemanager-agfood/README.md b/sdk/agfood/azure-resourcemanager-agfood/README.md new file mode 100644 index 000000000000..dc16e79c80d3 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/README.md @@ -0,0 +1,99 @@ +# Azure Resource Manager Agfood client library for Java + +Azure Resource Manager Agfood client library for Java. + +This package contains Microsoft Azure SDK for Agfood Management SDK. APIs documentation for Azure AgFoodPlatform Resource Provider Service. Package tag package-2020-05-12-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-agfood;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-agfood + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, `azure` client can be authenticated by following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +AgfoodManager manager = AgfoodManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/master/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/identity/azure-identity +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/DESIGN.md diff --git a/sdk/agfood/azure-resourcemanager-agfood/pom.xml b/sdk/agfood/azure-resourcemanager-agfood/pom.xml new file mode 100644 index 000000000000..166a55ee51d8 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-agfood + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Agfood Management + This package contains Microsoft Azure SDK for Agfood Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. APIs documentation for Azure AgFoodPlatform Resource Provider Service. Package tag package-2020-05-12-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + + com.azure + azure-core + 1.15.0 + + + com.azure + azure-core-management + 1.2.1 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + + diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/AgfoodManager.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/AgfoodManager.java new file mode 100644 index 000000000000..bece40f9f484 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/AgfoodManager.java @@ -0,0 +1,251 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.AzureAgFoodPlatformRPService; +import com.azure.resourcemanager.agfood.implementation.AzureAgFoodPlatformRPServiceBuilder; +import com.azure.resourcemanager.agfood.implementation.ExtensionsImpl; +import com.azure.resourcemanager.agfood.implementation.FarmBeatsModelsImpl; +import com.azure.resourcemanager.agfood.implementation.LocationsImpl; +import com.azure.resourcemanager.agfood.implementation.OperationsImpl; +import com.azure.resourcemanager.agfood.models.Extensions; +import com.azure.resourcemanager.agfood.models.FarmBeatsModels; +import com.azure.resourcemanager.agfood.models.Locations; +import com.azure.resourcemanager.agfood.models.Operations; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Entry point to AgfoodManager. APIs documentation for Azure AgFoodPlatform Resource Provider Service. */ +public final class AgfoodManager { + private Extensions extensions; + + private FarmBeatsModels farmBeatsModels; + + private Locations locations; + + private Operations operations; + + private final AzureAgFoodPlatformRPService clientObject; + + private AgfoodManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new AzureAgFoodPlatformRPServiceBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Agfood service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Agfood service API instance. + */ + public static AgfoodManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Gets a Configurable instance that can be used to create AgfoodManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new AgfoodManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private final ClientLogger logger = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private RetryPolicy retryPolicy; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = Objects.requireNonNull(defaultPollInterval, "'retryPolicy' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Agfood service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Agfood service API instance. + */ + public AgfoodManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder + .append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.agfood") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder + .append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (retryPolicy == null) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new RequestIdPolicy()); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies + .add( + new BearerTokenAuthenticationPolicy( + credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); + policies.addAll(this.policies); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new AgfoodManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of Extensions. */ + public Extensions extensions() { + if (this.extensions == null) { + this.extensions = new ExtensionsImpl(clientObject.getExtensions(), this); + } + return extensions; + } + + /** @return Resource collection API of FarmBeatsModels. */ + public FarmBeatsModels farmBeatsModels() { + if (this.farmBeatsModels == null) { + this.farmBeatsModels = new FarmBeatsModelsImpl(clientObject.getFarmBeatsModels(), this); + } + return farmBeatsModels; + } + + /** @return Resource collection API of Locations. */ + public Locations locations() { + if (this.locations == null) { + this.locations = new LocationsImpl(clientObject.getLocations(), this); + } + return locations; + } + + /** @return Resource collection API of Operations. */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * @return Wrapped service client AzureAgFoodPlatformRPService providing direct access to the underlying + * auto-generated API implementation, based on Azure REST API. + */ + public AzureAgFoodPlatformRPService serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/AzureAgFoodPlatformRPService.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/AzureAgFoodPlatformRPService.java new file mode 100644 index 000000000000..1f4a832f73b9 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/AzureAgFoodPlatformRPService.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for AzureAgFoodPlatformRPService class. */ +public interface AzureAgFoodPlatformRPService { + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the ExtensionsClient object to access its operations. + * + * @return the ExtensionsClient object. + */ + ExtensionsClient getExtensions(); + + /** + * Gets the FarmBeatsModelsClient object to access its operations. + * + * @return the FarmBeatsModelsClient object. + */ + FarmBeatsModelsClient getFarmBeatsModels(); + + /** + * Gets the LocationsClient object to access its operations. + * + * @return the LocationsClient object. + */ + LocationsClient getLocations(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/ExtensionsClient.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/ExtensionsClient.java new file mode 100644 index 000000000000..ca1db3af4262 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/ExtensionsClient.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.agfood.fluent.models.ExtensionInner; + +/** An instance of this class provides access to all the operations defined in ExtensionsClient. */ +public interface ExtensionsClient { + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ExtensionInner create(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ExtensionInner get(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ExtensionInner update(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByFarmBeats(String resourceGroupName, String farmBeatsResourceName); + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param extensionId Id of extension resource. + * @param extensionCategory Category of extension (weather/sensor/satellite etc.). + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByFarmBeats( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken, + Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/FarmBeatsModelsClient.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/FarmBeatsModelsClient.java new file mode 100644 index 000000000000..50ecfa61d204 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/FarmBeatsModelsClient.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.agfood.fluent.models.FarmBeatsInner; +import com.azure.resourcemanager.agfood.models.FarmBeatsUpdateRequestModel; + +/** An instance of this class provides access to all the operations defined in FarmBeatsModelsClient. */ +public interface FarmBeatsModelsClient { + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FarmBeatsInner getByResourceGroup(String resourceGroupName, String farmBeatsResourceName); + + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String farmBeatsResourceName, Context context); + + /** + * Create or update FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body FarmBeats resource create or update request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FarmBeatsInner createOrUpdate(String farmBeatsResourceName, String resourceGroupName, FarmBeatsInner body); + + /** + * Create or update FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body FarmBeats resource create or update request object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsInner body, Context context); + + /** + * Update a FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body Request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + FarmBeatsInner update(String farmBeatsResourceName, String resourceGroupName, FarmBeatsUpdateRequestModel body); + + /** + * Update a FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body Request object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsUpdateRequestModel body, Context context); + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String farmBeatsResourceName); + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String farmBeatsResourceName, Context context); + + /** + * Lists the FarmBeats instances for a subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists the FarmBeats instances for a subscription. + * + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Integer maxPageSize, String skipToken, Context context); + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Continuation token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup( + String resourceGroupName, Integer maxPageSize, String skipToken, Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/LocationsClient.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/LocationsClient.java new file mode 100644 index 000000000000..c2df4d5340e6 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/LocationsClient.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.agfood.fluent.models.CheckNameAvailabilityResponseInner; +import com.azure.resourcemanager.agfood.models.CheckNameAvailabilityRequest; + +/** An instance of this class provides access to all the operations defined in LocationsClient. */ +public interface LocationsClient { + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + CheckNameAvailabilityResponseInner checkNameAvailability(CheckNameAvailabilityRequest body); + + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response checkNameAvailabilityWithResponse( + CheckNameAvailabilityRequest body, Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/OperationsClient.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/OperationsClient.java new file mode 100644 index 000000000000..53587a96b1e7 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/OperationsClient.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.resourcemanager.agfood.fluent.models.OperationInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/CheckNameAvailabilityResponseInner.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/CheckNameAvailabilityResponseInner.java new file mode 100644 index 000000000000..c2e6a6230037 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/CheckNameAvailabilityResponseInner.java @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.models.CheckNameAvailabilityReason; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The check availability result. */ +@Fluent +public final class CheckNameAvailabilityResponseInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(CheckNameAvailabilityResponseInner.class); + + /* + * Indicates if the resource name is available. + */ + @JsonProperty(value = "nameAvailable") + private Boolean nameAvailable; + + /* + * The reason why the given name is not available. + */ + @JsonProperty(value = "reason") + private CheckNameAvailabilityReason reason; + + /* + * Detailed reason why the given name is available. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get the nameAvailable property: Indicates if the resource name is available. + * + * @return the nameAvailable value. + */ + public Boolean nameAvailable() { + return this.nameAvailable; + } + + /** + * Set the nameAvailable property: Indicates if the resource name is available. + * + * @param nameAvailable the nameAvailable value to set. + * @return the CheckNameAvailabilityResponseInner object itself. + */ + public CheckNameAvailabilityResponseInner withNameAvailable(Boolean nameAvailable) { + this.nameAvailable = nameAvailable; + return this; + } + + /** + * Get the reason property: The reason why the given name is not available. + * + * @return the reason value. + */ + public CheckNameAvailabilityReason reason() { + return this.reason; + } + + /** + * Set the reason property: The reason why the given name is not available. + * + * @param reason the reason value to set. + * @return the CheckNameAvailabilityResponseInner object itself. + */ + public CheckNameAvailabilityResponseInner withReason(CheckNameAvailabilityReason reason) { + this.reason = reason; + return this; + } + + /** + * Get the message property: Detailed reason why the given name is available. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * Set the message property: Detailed reason why the given name is available. + * + * @param message the message value to set. + * @return the CheckNameAvailabilityResponseInner object itself. + */ + public CheckNameAvailabilityResponseInner withMessage(String message) { + this.message = message; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/ExtensionInner.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/ExtensionInner.java new file mode 100644 index 000000000000..fba4ae1bb09e --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/ExtensionInner.java @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.annotation.JsonFlatten; +import com.azure.core.management.ProxyResource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Extension resource. */ +@JsonFlatten +@Immutable +public class ExtensionInner extends ProxyResource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ExtensionInner.class); + + /* + * Metadata pertaining to creation and last modification of the resource. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /* + * The ETag value to implement optimistic concurrency. + */ + @JsonProperty(value = "eTag", access = JsonProperty.Access.WRITE_ONLY) + private String etag; + + /* + * Extension Id. + */ + @JsonProperty(value = "properties.extensionId", access = JsonProperty.Access.WRITE_ONLY) + private String extensionId; + + /* + * Extension category. e.g. weather/sensor/satellite. + */ + @JsonProperty(value = "properties.extensionCategory", access = JsonProperty.Access.WRITE_ONLY) + private String extensionCategory; + + /* + * Installed extension version. + */ + @JsonProperty(value = "properties.installedExtensionVersion", access = JsonProperty.Access.WRITE_ONLY) + private String installedExtensionVersion; + + /* + * Extension auth link. + */ + @JsonProperty(value = "properties.extensionAuthLink", access = JsonProperty.Access.WRITE_ONLY) + private String extensionAuthLink; + + /* + * Extension api docs link. + */ + @JsonProperty(value = "properties.extensionApiDocsLink", access = JsonProperty.Access.WRITE_ONLY) + private String extensionApiDocsLink; + + /** + * Get the systemData property: Metadata pertaining to creation and last modification of the resource. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the etag property: The ETag value to implement optimistic concurrency. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Get the extensionId property: Extension Id. + * + * @return the extensionId value. + */ + public String extensionId() { + return this.extensionId; + } + + /** + * Get the extensionCategory property: Extension category. e.g. weather/sensor/satellite. + * + * @return the extensionCategory value. + */ + public String extensionCategory() { + return this.extensionCategory; + } + + /** + * Get the installedExtensionVersion property: Installed extension version. + * + * @return the installedExtensionVersion value. + */ + public String installedExtensionVersion() { + return this.installedExtensionVersion; + } + + /** + * Get the extensionAuthLink property: Extension auth link. + * + * @return the extensionAuthLink value. + */ + public String extensionAuthLink() { + return this.extensionAuthLink; + } + + /** + * Get the extensionApiDocsLink property: Extension api docs link. + * + * @return the extensionApiDocsLink value. + */ + public String extensionApiDocsLink() { + return this.extensionApiDocsLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/FarmBeatsInner.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/FarmBeatsInner.java new file mode 100644 index 000000000000..e45eeaedb545 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/FarmBeatsInner.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.annotation.JsonFlatten; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.models.ProvisioningState; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** FarmBeats ARM Resource. */ +@JsonFlatten +@Immutable +public class FarmBeatsInner extends Resource { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FarmBeatsInner.class); + + /* + * Metadata pertaining to creation and last modification of the resource. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /* + * Uri of the FarmBeats instance. + */ + @JsonProperty(value = "properties.instanceUri", access = JsonProperty.Access.WRITE_ONLY) + private String instanceUri; + + /* + * FarmBeats instance provisioning state. + */ + @JsonProperty(value = "properties.provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private ProvisioningState provisioningState; + + /** + * Get the systemData property: Metadata pertaining to creation and last modification of the resource. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the instanceUri property: Uri of the FarmBeats instance. + * + * @return the instanceUri value. + */ + public String instanceUri() { + return this.instanceUri; + } + + /** + * Get the provisioningState property: FarmBeats instance provisioning state. + * + * @return the provisioningState value. + */ + public ProvisioningState provisioningState() { + return this.provisioningState; + } + + /** {@inheritDoc} */ + @Override + public FarmBeatsInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public FarmBeatsInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/OperationInner.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/OperationInner.java new file mode 100644 index 000000000000..a6797a26b74f --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/OperationInner.java @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.models.ActionType; +import com.azure.resourcemanager.agfood.models.OperationDisplay; +import com.azure.resourcemanager.agfood.models.Origin; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Details of a REST API operation, returned from the Resource Provider Operations API. */ +@Fluent +public final class OperationInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationInner.class); + + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). + * Examples: "Microsoft.Compute/virtualMachines/write", + * "Microsoft.Compute/virtualMachines/capture/action" + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for + * data-plane operations and "false" for ARM/control-plane operations. + */ + @JsonProperty(value = "isDataAction", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access + * Control (RBAC) and audit logs UX. Default value is "user,system" + */ + @JsonProperty(value = "origin", access = JsonProperty.Access.WRITE_ONLY) + private Origin origin; + + /* + * Enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + */ + @JsonProperty(value = "actionType", access = JsonProperty.Access.WRITE_ONLY) + private ActionType actionType; + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: Localized display information for this particular operation. + * + * @param display the display value to set. + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/package-info.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/package-info.java new file mode 100644 index 000000000000..3719d8a5d44e --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the inner data models for AzureAgFoodPlatformRPService. APIs documentation for Azure + * AgFoodPlatform Resource Provider Service. + */ +package com.azure.resourcemanager.agfood.fluent.models; diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/package-info.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/package-info.java new file mode 100644 index 000000000000..9d5536c11562 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/fluent/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the service clients for AzureAgFoodPlatformRPService. APIs documentation for Azure AgFoodPlatform + * Resource Provider Service. + */ +package com.azure.resourcemanager.agfood.fluent; diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/AzureAgFoodPlatformRPServiceBuilder.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/AzureAgFoodPlatformRPServiceBuilder.java new file mode 100644 index 000000000000..ee9e1f866241 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/AzureAgFoodPlatformRPServiceBuilder.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** A builder for creating a new instance of the AzureAgFoodPlatformRPServiceImpl type. */ +@ServiceClientBuilder(serviceClients = {AzureAgFoodPlatformRPServiceImpl.class}) +public final class AzureAgFoodPlatformRPServiceBuilder { + /* + * The ID of the target subscription. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the AzureAgFoodPlatformRPServiceBuilder. + */ + public AzureAgFoodPlatformRPServiceBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the AzureAgFoodPlatformRPServiceBuilder. + */ + public AzureAgFoodPlatformRPServiceBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the AzureAgFoodPlatformRPServiceBuilder. + */ + public AzureAgFoodPlatformRPServiceBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the AzureAgFoodPlatformRPServiceBuilder. + */ + public AzureAgFoodPlatformRPServiceBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the AzureAgFoodPlatformRPServiceBuilder. + */ + public AzureAgFoodPlatformRPServiceBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the AzureAgFoodPlatformRPServiceBuilder. + */ + public AzureAgFoodPlatformRPServiceBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of AzureAgFoodPlatformRPServiceImpl with the provided parameters. + * + * @return an instance of AzureAgFoodPlatformRPServiceImpl. + */ + public AzureAgFoodPlatformRPServiceImpl buildClient() { + if (endpoint == null) { + this.endpoint = "https://management.azure.com"; + } + if (environment == null) { + this.environment = AzureEnvironment.AZURE; + } + if (defaultPollInterval == null) { + this.defaultPollInterval = Duration.ofSeconds(30); + } + if (pipeline == null) { + this.pipeline = + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(); + } + if (serializerAdapter == null) { + this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter(); + } + AzureAgFoodPlatformRPServiceImpl client = + new AzureAgFoodPlatformRPServiceImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/AzureAgFoodPlatformRPServiceImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/AzureAgFoodPlatformRPServiceImpl.java new file mode 100644 index 000000000000..fd134eecd124 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/AzureAgFoodPlatformRPServiceImpl.java @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.agfood.fluent.AzureAgFoodPlatformRPService; +import com.azure.resourcemanager.agfood.fluent.ExtensionsClient; +import com.azure.resourcemanager.agfood.fluent.FarmBeatsModelsClient; +import com.azure.resourcemanager.agfood.fluent.LocationsClient; +import com.azure.resourcemanager.agfood.fluent.OperationsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.Map; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the AzureAgFoodPlatformRPServiceImpl type. */ +@ServiceClient(builder = AzureAgFoodPlatformRPServiceBuilder.class) +public final class AzureAgFoodPlatformRPServiceImpl implements AzureAgFoodPlatformRPService { + private final ClientLogger logger = new ClientLogger(AzureAgFoodPlatformRPServiceImpl.class); + + /** The ID of the target subscription. */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** The default poll interval for long-running operation. */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** The ExtensionsClient object to access its operations. */ + private final ExtensionsClient extensions; + + /** + * Gets the ExtensionsClient object to access its operations. + * + * @return the ExtensionsClient object. + */ + public ExtensionsClient getExtensions() { + return this.extensions; + } + + /** The FarmBeatsModelsClient object to access its operations. */ + private final FarmBeatsModelsClient farmBeatsModels; + + /** + * Gets the FarmBeatsModelsClient object to access its operations. + * + * @return the FarmBeatsModelsClient object. + */ + public FarmBeatsModelsClient getFarmBeatsModels() { + return this.farmBeatsModels; + } + + /** The LocationsClient object to access its operations. */ + private final LocationsClient locations; + + /** + * Gets the LocationsClient object to access its operations. + * + * @return the LocationsClient object. + */ + public LocationsClient getLocations() { + return this.locations; + } + + /** The OperationsClient object to access its operations. */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * Initializes an instance of AzureAgFoodPlatformRPService client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param subscriptionId The ID of the target subscription. + * @param endpoint server parameter. + */ + AzureAgFoodPlatformRPServiceImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String subscriptionId, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.apiVersion = "2020-05-12-preview"; + this.extensions = new ExtensionsClientImpl(this); + this.farmBeatsModels = new FarmBeatsModelsClientImpl(this); + this.locations = new LocationsClientImpl(this); + this.operations = new OperationsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + for (Map.Entry entry : this.getContext().getValues().entrySet()) { + context = context.addData(entry.getKey(), entry.getValue()); + } + return context; + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult( + Mono>> activationResponse, + HttpPipeline httpPipeline, + Type pollResultType, + Type finalResultType, + Context context) { + return PollerFactory + .create( + serializerAdapter, + httpPipeline, + pollResultType, + finalResultType, + defaultPollInterval, + activationResponse, + context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = + new HttpResponseImpl( + lroError.getResponseStatusCode(), lroError.getResponseHeaders(), lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = + this + .getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + logger.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(s); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/CheckNameAvailabilityResponseImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/CheckNameAvailabilityResponseImpl.java new file mode 100644 index 000000000000..808c1e23d254 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/CheckNameAvailabilityResponseImpl.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.resourcemanager.agfood.fluent.models.CheckNameAvailabilityResponseInner; +import com.azure.resourcemanager.agfood.models.CheckNameAvailabilityReason; +import com.azure.resourcemanager.agfood.models.CheckNameAvailabilityResponse; + +public final class CheckNameAvailabilityResponseImpl implements CheckNameAvailabilityResponse { + private CheckNameAvailabilityResponseInner innerObject; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + CheckNameAvailabilityResponseImpl( + CheckNameAvailabilityResponseInner innerObject, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public Boolean nameAvailable() { + return this.innerModel().nameAvailable(); + } + + public CheckNameAvailabilityReason reason() { + return this.innerModel().reason(); + } + + public String message() { + return this.innerModel().message(); + } + + public CheckNameAvailabilityResponseInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionImpl.java new file mode 100644 index 000000000000..3dd047b2e2d5 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionImpl.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.agfood.fluent.models.ExtensionInner; +import com.azure.resourcemanager.agfood.models.Extension; + +public final class ExtensionImpl implements Extension { + private ExtensionInner innerObject; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + ExtensionImpl(ExtensionInner innerObject, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String etag() { + return this.innerModel().etag(); + } + + public String extensionId() { + return this.innerModel().extensionId(); + } + + public String extensionCategory() { + return this.innerModel().extensionCategory(); + } + + public String installedExtensionVersion() { + return this.innerModel().installedExtensionVersion(); + } + + public String extensionAuthLink() { + return this.innerModel().extensionAuthLink(); + } + + public String extensionApiDocsLink() { + return this.innerModel().extensionApiDocsLink(); + } + + public ExtensionInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionsClientImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionsClientImpl.java new file mode 100644 index 000000000000..3e0421cc9637 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionsClientImpl.java @@ -0,0 +1,1165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.ExtensionsClient; +import com.azure.resourcemanager.agfood.fluent.models.ExtensionInner; +import com.azure.resourcemanager.agfood.models.ExtensionListResponse; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in ExtensionsClient. */ +public final class ExtensionsClientImpl implements ExtensionsClient { + private final ClientLogger logger = new ClientLogger(ExtensionsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final ExtensionsService service; + + /** The service client containing this operation class. */ + private final AzureAgFoodPlatformRPServiceImpl client; + + /** + * Initializes an instance of ExtensionsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtensionsClientImpl(AzureAgFoodPlatformRPServiceImpl client) { + this.service = + RestProxy.create(ExtensionsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureAgFoodPlatformRPServiceExtensions to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureAgFoodPlatformR") + private interface ExtensionsService { + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}") + @ExpectedResponses({201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> create( + @HostParam("$host") String endpoint, + @PathParam("extensionId") String extensionId, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get( + @HostParam("$host") String endpoint, + @PathParam("extensionId") String extensionId, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("extensionId") String extensionId, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}/extensions/{extensionId}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @PathParam("extensionId") String extensionId, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}/extensions") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByFarmBeats( + @HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @QueryParam("extensionId") String extensionId, + @QueryParam("extensionCategory") String extensionCategory, + @QueryParam("$maxPageSize") Integer maxPageSize, + @QueryParam("$skipToken") String skipToken, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByFarmBeatsNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .create( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .create( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context); + } + + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName) { + return createWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtensionInner create(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + return createAsync(extensionId, farmBeatsResourceName, resourceGroupName).block(); + } + + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + return createWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName, context).block(); + } + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .get( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .get( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context); + } + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + return getWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtensionInner get(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + return getAsync(extensionId, farmBeatsResourceName, resourceGroupName).block(); + } + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + return getWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName, context).block(); + } + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context); + } + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName) { + return updateWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ExtensionInner update(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + return updateAsync(extensionId, farmBeatsResourceName, resourceGroupName).block(); + } + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + return updateWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName, context).block(); + } + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (extensionId == null) { + return Mono.error(new IllegalArgumentException("Parameter extensionId is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + extensionId, + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context); + } + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + return deleteWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName) + .flatMap((Response res) -> Mono.empty()); + } + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + deleteAsync(extensionId, farmBeatsResourceName, resourceGroupName).block(); + } + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + return deleteWithResponseAsync(extensionId, farmBeatsResourceName, resourceGroupName, context).block(); + } + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param extensionId Id of extension resource. + * @param extensionCategory Category of extension (weather/sensor/satellite etc.). + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByFarmBeatsSinglePageAsync( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .listByFarmBeats( + this.client.getEndpoint(), + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + farmBeatsResourceName, + extensionId, + extensionCategory, + maxPageSize, + skipToken, + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param extensionId Id of extension resource. + * @param extensionCategory Category of extension (weather/sensor/satellite etc.). + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByFarmBeatsSinglePageAsync( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken, + Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByFarmBeats( + this.client.getEndpoint(), + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + farmBeatsResourceName, + extensionId, + extensionCategory, + maxPageSize, + skipToken, + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param extensionId Id of extension resource. + * @param extensionCategory Category of extension (weather/sensor/satellite etc.). + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByFarmBeatsAsync( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken) { + return new PagedFlux<>( + () -> + listByFarmBeatsSinglePageAsync( + resourceGroupName, farmBeatsResourceName, extensionId, extensionCategory, maxPageSize, skipToken), + nextLink -> listByFarmBeatsNextSinglePageAsync(nextLink)); + } + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByFarmBeatsAsync(String resourceGroupName, String farmBeatsResourceName) { + final String extensionId = null; + final String extensionCategory = null; + final Integer maxPageSize = null; + final String skipToken = null; + return new PagedFlux<>( + () -> + listByFarmBeatsSinglePageAsync( + resourceGroupName, farmBeatsResourceName, extensionId, extensionCategory, maxPageSize, skipToken), + nextLink -> listByFarmBeatsNextSinglePageAsync(nextLink)); + } + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param extensionId Id of extension resource. + * @param extensionCategory Category of extension (weather/sensor/satellite etc.). + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByFarmBeatsAsync( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken, + Context context) { + return new PagedFlux<>( + () -> + listByFarmBeatsSinglePageAsync( + resourceGroupName, + farmBeatsResourceName, + extensionId, + extensionCategory, + maxPageSize, + skipToken, + context), + nextLink -> listByFarmBeatsNextSinglePageAsync(nextLink, context)); + } + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByFarmBeats(String resourceGroupName, String farmBeatsResourceName) { + final String extensionId = null; + final String extensionCategory = null; + final Integer maxPageSize = null; + final String skipToken = null; + return new PagedIterable<>( + listByFarmBeatsAsync( + resourceGroupName, farmBeatsResourceName, extensionId, extensionCategory, maxPageSize, skipToken)); + } + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param extensionId Id of extension resource. + * @param extensionCategory Category of extension (weather/sensor/satellite etc.). + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByFarmBeats( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken, + Context context) { + return new PagedIterable<>( + listByFarmBeatsAsync( + resourceGroupName, + farmBeatsResourceName, + extensionId, + extensionCategory, + maxPageSize, + skipToken, + context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByFarmBeatsNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByFarmBeatsNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByFarmBeatsNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByFarmBeatsNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionsImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionsImpl.java new file mode 100644 index 000000000000..5b89dd49af43 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/ExtensionsImpl.java @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.ExtensionsClient; +import com.azure.resourcemanager.agfood.fluent.models.ExtensionInner; +import com.azure.resourcemanager.agfood.models.Extension; +import com.azure.resourcemanager.agfood.models.Extensions; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class ExtensionsImpl implements Extensions { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ExtensionsImpl.class); + + private final ExtensionsClient innerClient; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + public ExtensionsImpl(ExtensionsClient innerClient, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Extension create(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + ExtensionInner inner = this.serviceClient().create(extensionId, farmBeatsResourceName, resourceGroupName); + if (inner != null) { + return new ExtensionImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response createWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + Response inner = + this.serviceClient().createWithResponse(extensionId, farmBeatsResourceName, resourceGroupName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ExtensionImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Extension get(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + ExtensionInner inner = this.serviceClient().get(extensionId, farmBeatsResourceName, resourceGroupName); + if (inner != null) { + return new ExtensionImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + Response inner = + this.serviceClient().getWithResponse(extensionId, farmBeatsResourceName, resourceGroupName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ExtensionImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public Extension update(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + ExtensionInner inner = this.serviceClient().update(extensionId, farmBeatsResourceName, resourceGroupName); + if (inner != null) { + return new ExtensionImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response updateWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + Response inner = + this.serviceClient().updateWithResponse(extensionId, farmBeatsResourceName, resourceGroupName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ExtensionImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void delete(String extensionId, String farmBeatsResourceName, String resourceGroupName) { + this.serviceClient().delete(extensionId, farmBeatsResourceName, resourceGroupName); + } + + public Response deleteWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context) { + return this.serviceClient().deleteWithResponse(extensionId, farmBeatsResourceName, resourceGroupName, context); + } + + public PagedIterable listByFarmBeats(String resourceGroupName, String farmBeatsResourceName) { + PagedIterable inner = + this.serviceClient().listByFarmBeats(resourceGroupName, farmBeatsResourceName); + return Utils.mapPage(inner, inner1 -> new ExtensionImpl(inner1, this.manager())); + } + + public PagedIterable listByFarmBeats( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken, + Context context) { + PagedIterable inner = + this + .serviceClient() + .listByFarmBeats( + resourceGroupName, + farmBeatsResourceName, + extensionId, + extensionCategory, + maxPageSize, + skipToken, + context); + return Utils.mapPage(inner, inner1 -> new ExtensionImpl(inner1, this.manager())); + } + + private ExtensionsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsImpl.java new file mode 100644 index 000000000000..7e4334db5824 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsImpl.java @@ -0,0 +1,187 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.agfood.fluent.models.FarmBeatsInner; +import com.azure.resourcemanager.agfood.models.FarmBeats; +import com.azure.resourcemanager.agfood.models.FarmBeatsUpdateRequestModel; +import com.azure.resourcemanager.agfood.models.ProvisioningState; +import java.util.Collections; +import java.util.Map; + +public final class FarmBeatsImpl implements FarmBeats, FarmBeats.Definition, FarmBeats.Update { + private FarmBeatsInner innerObject; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + public String id() { + return this.innerModel().id(); + } + + public String name() { + return this.innerModel().name(); + } + + public String type() { + return this.innerModel().type(); + } + + public String location() { + return this.innerModel().location(); + } + + public Map tags() { + Map inner = this.innerModel().tags(); + if (inner != null) { + return Collections.unmodifiableMap(inner); + } else { + return Collections.emptyMap(); + } + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public String instanceUri() { + return this.innerModel().instanceUri(); + } + + public ProvisioningState provisioningState() { + return this.innerModel().provisioningState(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public FarmBeatsInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } + + private String farmBeatsResourceName; + + private String resourceGroupName; + + private FarmBeatsUpdateRequestModel updateBody; + + public FarmBeatsImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public FarmBeats create() { + this.innerObject = + serviceManager + .serviceClient() + .getFarmBeatsModels() + .createOrUpdateWithResponse(farmBeatsResourceName, resourceGroupName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public FarmBeats create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getFarmBeatsModels() + .createOrUpdateWithResponse(farmBeatsResourceName, resourceGroupName, this.innerModel(), context) + .getValue(); + return this; + } + + FarmBeatsImpl(String name, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerObject = new FarmBeatsInner(); + this.serviceManager = serviceManager; + this.farmBeatsResourceName = name; + } + + public FarmBeatsImpl update() { + this.updateBody = new FarmBeatsUpdateRequestModel(); + return this; + } + + public FarmBeats apply() { + this.innerObject = + serviceManager + .serviceClient() + .getFarmBeatsModels() + .updateWithResponse(farmBeatsResourceName, resourceGroupName, updateBody, Context.NONE) + .getValue(); + return this; + } + + public FarmBeats apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getFarmBeatsModels() + .updateWithResponse(farmBeatsResourceName, resourceGroupName, updateBody, context) + .getValue(); + return this; + } + + FarmBeatsImpl(FarmBeatsInner innerObject, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.farmBeatsResourceName = Utils.getValueFromIdByName(innerObject.id(), "farmBeats"); + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + } + + public FarmBeats refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getFarmBeatsModels() + .getByResourceGroupWithResponse(resourceGroupName, farmBeatsResourceName, Context.NONE) + .getValue(); + return this; + } + + public FarmBeats refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getFarmBeatsModels() + .getByResourceGroupWithResponse(resourceGroupName, farmBeatsResourceName, context) + .getValue(); + return this; + } + + public FarmBeatsImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public FarmBeatsImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public FarmBeatsImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateBody.withTags(tags); + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsModelsClientImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsModelsClientImpl.java new file mode 100644 index 000000000000..a7ae047ca22d --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsModelsClientImpl.java @@ -0,0 +1,1334 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.FarmBeatsModelsClient; +import com.azure.resourcemanager.agfood.fluent.models.FarmBeatsInner; +import com.azure.resourcemanager.agfood.models.FarmBeatsListResponse; +import com.azure.resourcemanager.agfood.models.FarmBeatsUpdateRequestModel; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in FarmBeatsModelsClient. */ +public final class FarmBeatsModelsClientImpl implements FarmBeatsModelsClient { + private final ClientLogger logger = new ClientLogger(FarmBeatsModelsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final FarmBeatsModelsService service; + + /** The service client containing this operation class. */ + private final AzureAgFoodPlatformRPServiceImpl client; + + /** + * Initializes an instance of FarmBeatsModelsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FarmBeatsModelsClientImpl(AzureAgFoodPlatformRPServiceImpl client) { + this.service = + RestProxy.create(FarmBeatsModelsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureAgFoodPlatformRPServiceFarmBeatsModels to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureAgFoodPlatformR") + private interface FarmBeatsModelsService { + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate( + @HostParam("$host") String endpoint, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") FarmBeatsInner body, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") FarmBeatsUpdateRequestModel body, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats/{farmBeatsResourceName}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @PathParam("farmBeatsResourceName") String farmBeatsResourceName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/farmBeats") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("$maxPageSize") Integer maxPageSize, + @QueryParam("$skipToken") String skipToken, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AgFoodPlatform" + + "/farmBeats") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @QueryParam("$maxPageSize") Integer maxPageSize, + @QueryParam("$skipToken") String skipToken, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroupNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String farmBeatsResourceName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + farmBeatsResourceName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String farmBeatsResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .getByResourceGroup( + this.client.getEndpoint(), + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + farmBeatsResourceName, + accept, + context); + } + + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String farmBeatsResourceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, farmBeatsResourceName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FarmBeatsInner getByResourceGroup(String resourceGroupName, String farmBeatsResourceName) { + return getByResourceGroupAsync(resourceGroupName, farmBeatsResourceName).block(); + } + + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String farmBeatsResourceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, farmBeatsResourceName, context).block(); + } + + /** + * Create or update FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body FarmBeats resource create or update request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsInner body) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createOrUpdate( + this.client.getEndpoint(), + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + body, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body FarmBeats resource create or update request object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsInner body, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createOrUpdate( + this.client.getEndpoint(), + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + body, + accept, + context); + } + + /** + * Create or update FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body FarmBeats resource create or update request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsInner body) { + return createOrUpdateWithResponseAsync(farmBeatsResourceName, resourceGroupName, body) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create or update FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body FarmBeats resource create or update request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FarmBeatsInner createOrUpdate(String farmBeatsResourceName, String resourceGroupName, FarmBeatsInner body) { + return createOrUpdateAsync(farmBeatsResourceName, resourceGroupName, body).block(); + } + + /** + * Create or update FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body FarmBeats resource create or update request object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsInner body, Context context) { + return createOrUpdateWithResponseAsync(farmBeatsResourceName, resourceGroupName, body, context).block(); + } + + /** + * Update a FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body Request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsUpdateRequestModel body) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + body, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update a FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body Request object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsUpdateRequestModel body, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + farmBeatsResourceName, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + body, + accept, + context); + } + + /** + * Update a FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body Request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsUpdateRequestModel body) { + return updateWithResponseAsync(farmBeatsResourceName, resourceGroupName, body) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Update a FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body Request object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public FarmBeatsInner update( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsUpdateRequestModel body) { + return updateAsync(farmBeatsResourceName, resourceGroupName, body).block(); + } + + /** + * Update a FarmBeats resource. + * + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param body Request object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats ARM Resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String farmBeatsResourceName, String resourceGroupName, FarmBeatsUpdateRequestModel body, Context context) { + return updateWithResponseAsync(farmBeatsResourceName, resourceGroupName, body, context).block(); + } + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String farmBeatsResourceName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + farmBeatsResourceName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync( + String resourceGroupName, String farmBeatsResourceName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (farmBeatsResourceName == null) { + return Mono + .error(new IllegalArgumentException("Parameter farmBeatsResourceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + farmBeatsResourceName, + accept, + context); + } + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the completion. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String farmBeatsResourceName) { + return deleteWithResponseAsync(resourceGroupName, farmBeatsResourceName) + .flatMap((Response res) -> Mono.empty()); + } + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String farmBeatsResourceName) { + deleteAsync(resourceGroupName, farmBeatsResourceName).block(); + } + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String farmBeatsResourceName, Context context) { + return deleteWithResponseAsync(resourceGroupName, farmBeatsResourceName, context).block(); + } + + /** + * Lists the FarmBeats instances for a subscription. + * + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Integer maxPageSize, String skipToken) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .list( + this.client.getEndpoint(), + maxPageSize, + skipToken, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists the FarmBeats instances for a subscription. + * + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync( + Integer maxPageSize, String skipToken, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list( + this.client.getEndpoint(), + maxPageSize, + skipToken, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists the FarmBeats instances for a subscription. + * + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Integer maxPageSize, String skipToken) { + return new PagedFlux<>( + () -> listSinglePageAsync(maxPageSize, skipToken), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Lists the FarmBeats instances for a subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + final Integer maxPageSize = null; + final String skipToken = null; + return new PagedFlux<>( + () -> listSinglePageAsync(maxPageSize, skipToken), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Lists the FarmBeats instances for a subscription. + * + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Integer maxPageSize, String skipToken, Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(maxPageSize, skipToken, context), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists the FarmBeats instances for a subscription. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + final Integer maxPageSize = null; + final String skipToken = null; + return new PagedIterable<>(listAsync(maxPageSize, skipToken)); + } + + /** + * Lists the FarmBeats instances for a subscription. + * + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Integer maxPageSize, String skipToken, Context context) { + return new PagedIterable<>(listAsync(maxPageSize, skipToken, context)); + } + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Continuation token for getting next set of results. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroupName, Integer maxPageSize, String skipToken) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .listByResourceGroup( + this.client.getEndpoint(), + maxPageSize, + skipToken, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Continuation token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + String resourceGroupName, Integer maxPageSize, String skipToken, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup( + this.client.getEndpoint(), + maxPageSize, + skipToken, + resourceGroupName, + this.client.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Continuation token for getting next set of results. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync( + String resourceGroupName, Integer maxPageSize, String skipToken) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, maxPageSize, skipToken), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + final Integer maxPageSize = null; + final String skipToken = null; + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, maxPageSize, skipToken), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Continuation token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync( + String resourceGroupName, Integer maxPageSize, String skipToken, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, maxPageSize, skipToken, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + final Integer maxPageSize = null; + final String skipToken = null; + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, maxPageSize, skipToken)); + } + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Continuation token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup( + String resourceGroupName, Integer maxPageSize, String skipToken, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, maxPageSize, skipToken, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroupNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsModelsImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsModelsImpl.java new file mode 100644 index 000000000000..fd7b1fcf9e68 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/FarmBeatsModelsImpl.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.FarmBeatsModelsClient; +import com.azure.resourcemanager.agfood.fluent.models.FarmBeatsInner; +import com.azure.resourcemanager.agfood.models.FarmBeats; +import com.azure.resourcemanager.agfood.models.FarmBeatsModels; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class FarmBeatsModelsImpl implements FarmBeatsModels { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FarmBeatsModelsImpl.class); + + private final FarmBeatsModelsClient innerClient; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + public FarmBeatsModelsImpl( + FarmBeatsModelsClient innerClient, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public FarmBeats getByResourceGroup(String resourceGroupName, String farmBeatsResourceName) { + FarmBeatsInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, farmBeatsResourceName); + if (inner != null) { + return new FarmBeatsImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String farmBeatsResourceName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, farmBeatsResourceName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new FarmBeatsImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String farmBeatsResourceName) { + this.serviceClient().delete(resourceGroupName, farmBeatsResourceName); + } + + public Response deleteWithResponse(String resourceGroupName, String farmBeatsResourceName, Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, farmBeatsResourceName, context); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new FarmBeatsImpl(inner1, this.manager())); + } + + public PagedIterable list(Integer maxPageSize, String skipToken, Context context) { + PagedIterable inner = this.serviceClient().list(maxPageSize, skipToken, context); + return Utils.mapPage(inner, inner1 -> new FarmBeatsImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new FarmBeatsImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup( + String resourceGroupName, Integer maxPageSize, String skipToken, Context context) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName, maxPageSize, skipToken, context); + return Utils.mapPage(inner, inner1 -> new FarmBeatsImpl(inner1, this.manager())); + } + + public FarmBeats getById(String id) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String farmBeatsResourceName = Utils.getValueFromIdByName(id, "farmBeats"); + if (farmBeatsResourceName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'farmBeats'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, farmBeatsResourceName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String farmBeatsResourceName = Utils.getValueFromIdByName(id, "farmBeats"); + if (farmBeatsResourceName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'farmBeats'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, farmBeatsResourceName, context); + } + + public void deleteById(String id) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String farmBeatsResourceName = Utils.getValueFromIdByName(id, "farmBeats"); + if (farmBeatsResourceName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'farmBeats'.", id))); + } + this.deleteWithResponse(resourceGroupName, farmBeatsResourceName, Context.NONE).getValue(); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String farmBeatsResourceName = Utils.getValueFromIdByName(id, "farmBeats"); + if (farmBeatsResourceName == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'farmBeats'.", id))); + } + return this.deleteWithResponse(resourceGroupName, farmBeatsResourceName, context); + } + + private FarmBeatsModelsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } + + public FarmBeatsImpl define(String name) { + return new FarmBeatsImpl(name, this.manager()); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/LocationsClientImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/LocationsClientImpl.java new file mode 100644 index 000000000000..40f1bac930a6 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/LocationsClientImpl.java @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.LocationsClient; +import com.azure.resourcemanager.agfood.fluent.models.CheckNameAvailabilityResponseInner; +import com.azure.resourcemanager.agfood.models.CheckNameAvailabilityRequest; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in LocationsClient. */ +public final class LocationsClientImpl implements LocationsClient { + private final ClientLogger logger = new ClientLogger(LocationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final LocationsService service; + + /** The service client containing this operation class. */ + private final AzureAgFoodPlatformRPServiceImpl client; + + /** + * Initializes an instance of LocationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + LocationsClientImpl(AzureAgFoodPlatformRPServiceImpl client) { + this.service = + RestProxy.create(LocationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureAgFoodPlatformRPServiceLocations to be used by the proxy service + * to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureAgFoodPlatformR") + private interface LocationsService { + @Headers({"Content-Type: application/json"}) + @Post("/subscriptions/{subscriptionId}/providers/Microsoft.AgFoodPlatform/checkNameAvailability") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> checkNameAvailability( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") CheckNameAvailabilityRequest body, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> checkNameAvailabilityWithResponseAsync( + CheckNameAvailabilityRequest body) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .checkNameAvailability( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + body, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> checkNameAvailabilityWithResponseAsync( + CheckNameAvailabilityRequest body, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .checkNameAvailability( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + this.client.getApiVersion(), + body, + accept, + context); + } + + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono checkNameAvailabilityAsync(CheckNameAvailabilityRequest body) { + return checkNameAvailabilityWithResponseAsync(body) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public CheckNameAvailabilityResponseInner checkNameAvailability(CheckNameAvailabilityRequest body) { + return checkNameAvailabilityAsync(body).block(); + } + + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response checkNameAvailabilityWithResponse( + CheckNameAvailabilityRequest body, Context context) { + return checkNameAvailabilityWithResponseAsync(body, context).block(); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/LocationsImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/LocationsImpl.java new file mode 100644 index 000000000000..9acb1063df6a --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/LocationsImpl.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.LocationsClient; +import com.azure.resourcemanager.agfood.fluent.models.CheckNameAvailabilityResponseInner; +import com.azure.resourcemanager.agfood.models.CheckNameAvailabilityRequest; +import com.azure.resourcemanager.agfood.models.CheckNameAvailabilityResponse; +import com.azure.resourcemanager.agfood.models.Locations; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class LocationsImpl implements Locations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(LocationsImpl.class); + + private final LocationsClient innerClient; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + public LocationsImpl(LocationsClient innerClient, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public CheckNameAvailabilityResponse checkNameAvailability(CheckNameAvailabilityRequest body) { + CheckNameAvailabilityResponseInner inner = this.serviceClient().checkNameAvailability(body); + if (inner != null) { + return new CheckNameAvailabilityResponseImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response checkNameAvailabilityWithResponse( + CheckNameAvailabilityRequest body, Context context) { + Response inner = + this.serviceClient().checkNameAvailabilityWithResponse(body, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new CheckNameAvailabilityResponseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + private LocationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationImpl.java new file mode 100644 index 000000000000..9dae3c73afec --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationImpl.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.resourcemanager.agfood.fluent.models.OperationInner; +import com.azure.resourcemanager.agfood.models.ActionType; +import com.azure.resourcemanager.agfood.models.Operation; +import com.azure.resourcemanager.agfood.models.OperationDisplay; +import com.azure.resourcemanager.agfood.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + OperationImpl(OperationInner innerObject, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationsClientImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..620e7225900d --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationsClientImpl.java @@ -0,0 +1,269 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.OperationsClient; +import com.azure.resourcemanager.agfood.fluent.models.OperationInner; +import com.azure.resourcemanager.agfood.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public final class OperationsClientImpl implements OperationsClient { + private final ClientLogger logger = new ClientLogger(OperationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final AzureAgFoodPlatformRPServiceImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(AzureAgFoodPlatformRPServiceImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureAgFoodPlatformRPServiceOperations to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureAgFoodPlatformR") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.AgFoodPlatform/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("{nextLink}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationsImpl.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationsImpl.java new file mode 100644 index 000000000000..c8e81dfe9c3f --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.OperationsClient; +import com.azure.resourcemanager.agfood.fluent.models.OperationInner; +import com.azure.resourcemanager.agfood.models.Operation; +import com.azure.resourcemanager.agfood.models.Operations; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class OperationsImpl implements Operations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.agfood.AgfoodManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, com.azure.resourcemanager.agfood.AgfoodManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.agfood.AgfoodManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/Utils.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/Utils.java new file mode 100644 index 000000000000..4ae37e61049d --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/Utils.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class Utils { + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (segments.size() > 0 && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super( + PagedFlux + .create( + () -> + (continuationToken, pageSize) -> + Flux.fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> + new PagedResponseBase( + page.getRequest(), + page.getStatusCode(), + page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), + page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl, PagedResponse>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/package-info.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/package-info.java new file mode 100644 index 000000000000..5738992a0bda --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/implementation/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the implementations for AzureAgFoodPlatformRPService. APIs documentation for Azure AgFoodPlatform + * Resource Provider Service. + */ +package com.azure.resourcemanager.agfood.implementation; diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ActionType.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ActionType.java new file mode 100644 index 000000000000..df627757611d --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ActionType.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ActionType. */ +public final class ActionType extends ExpandableStringEnum { + /** Static value Internal for ActionType. */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + @JsonCreator + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** @return known ActionType values. */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityReason.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityReason.java new file mode 100644 index 000000000000..fd0305a1151e --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityReason.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for CheckNameAvailabilityReason. */ +public final class CheckNameAvailabilityReason extends ExpandableStringEnum { + /** Static value Invalid for CheckNameAvailabilityReason. */ + public static final CheckNameAvailabilityReason INVALID = fromString("Invalid"); + + /** Static value AlreadyExists for CheckNameAvailabilityReason. */ + public static final CheckNameAvailabilityReason ALREADY_EXISTS = fromString("AlreadyExists"); + + /** + * Creates or finds a CheckNameAvailabilityReason from its string representation. + * + * @param name a name to look for. + * @return the corresponding CheckNameAvailabilityReason. + */ + @JsonCreator + public static CheckNameAvailabilityReason fromString(String name) { + return fromString(name, CheckNameAvailabilityReason.class); + } + + /** @return known CheckNameAvailabilityReason values. */ + public static Collection values() { + return values(CheckNameAvailabilityReason.class); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityRequest.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityRequest.java new file mode 100644 index 000000000000..fc057f23c9d8 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityRequest.java @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The check availability request body. */ +@Fluent +public final class CheckNameAvailabilityRequest { + @JsonIgnore private final ClientLogger logger = new ClientLogger(CheckNameAvailabilityRequest.class); + + /* + * The name of the resource for which availability needs to be checked. + */ + @JsonProperty(value = "name") + private String name; + + /* + * The resource type. + */ + @JsonProperty(value = "type") + private String type; + + /** + * Get the name property: The name of the resource for which availability needs to be checked. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the resource for which availability needs to be checked. + * + * @param name the name value to set. + * @return the CheckNameAvailabilityRequest object itself. + */ + public CheckNameAvailabilityRequest withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type property: The resource type. + * + * @return the type value. + */ + public String type() { + return this.type; + } + + /** + * Set the type property: The resource type. + * + * @param type the type value to set. + * @return the CheckNameAvailabilityRequest object itself. + */ + public CheckNameAvailabilityRequest withType(String type) { + this.type = type; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityResponse.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityResponse.java new file mode 100644 index 000000000000..b5bebc451020 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/CheckNameAvailabilityResponse.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.resourcemanager.agfood.fluent.models.CheckNameAvailabilityResponseInner; + +/** An immutable client-side representation of CheckNameAvailabilityResponse. */ +public interface CheckNameAvailabilityResponse { + /** + * Gets the nameAvailable property: Indicates if the resource name is available. + * + * @return the nameAvailable value. + */ + Boolean nameAvailable(); + + /** + * Gets the reason property: The reason why the given name is not available. + * + * @return the reason value. + */ + CheckNameAvailabilityReason reason(); + + /** + * Gets the message property: Detailed reason why the given name is available. + * + * @return the message value. + */ + String message(); + + /** + * Gets the inner com.azure.resourcemanager.agfood.fluent.models.CheckNameAvailabilityResponseInner object. + * + * @return the inner object. + */ + CheckNameAvailabilityResponseInner innerModel(); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Extension.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Extension.java new file mode 100644 index 000000000000..dbee7b65d690 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Extension.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.agfood.fluent.models.ExtensionInner; + +/** An immutable client-side representation of Extension. */ +public interface Extension { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the systemData property: Metadata pertaining to creation and last modification of the resource. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the etag property: The ETag value to implement optimistic concurrency. + * + * @return the etag value. + */ + String etag(); + + /** + * Gets the extensionId property: Extension Id. + * + * @return the extensionId value. + */ + String extensionId(); + + /** + * Gets the extensionCategory property: Extension category. e.g. weather/sensor/satellite. + * + * @return the extensionCategory value. + */ + String extensionCategory(); + + /** + * Gets the installedExtensionVersion property: Installed extension version. + * + * @return the installedExtensionVersion value. + */ + String installedExtensionVersion(); + + /** + * Gets the extensionAuthLink property: Extension auth link. + * + * @return the extensionAuthLink value. + */ + String extensionAuthLink(); + + /** + * Gets the extensionApiDocsLink property: Extension api docs link. + * + * @return the extensionApiDocsLink value. + */ + String extensionApiDocsLink(); + + /** + * Gets the inner com.azure.resourcemanager.agfood.fluent.models.ExtensionInner object. + * + * @return the inner object. + */ + ExtensionInner innerModel(); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ExtensionListResponse.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ExtensionListResponse.java new file mode 100644 index 000000000000..4222940b8bd2 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ExtensionListResponse.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.models.ExtensionInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Paged response contains list of requested objects and a URL link to get the next set of results. */ +@Fluent +public final class ExtensionListResponse { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ExtensionListResponse.class); + + /* + * List of requested objects. + */ + @JsonProperty(value = "value") + private List value; + + /* + * Continuation link (absolute URI) to the next page of results in the + * list. + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: List of requested objects. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of requested objects. + * + * @param value the value value to set. + * @return the ExtensionListResponse object itself. + */ + public ExtensionListResponse withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: Continuation link (absolute URI) to the next page of results in the list. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Extensions.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Extensions.java new file mode 100644 index 000000000000..4966b08bde9f --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Extensions.java @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of Extensions. */ +public interface Extensions { + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + Extension create(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Install extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + Response createWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + Extension get(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Get installed extension details by extension id. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extension details by extension id. + */ + Response getWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + Extension update(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Upgrade to latest extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension resource. + */ + Response updateWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void delete(String extensionId, String farmBeatsResourceName, String resourceGroupName); + + /** + * Uninstall extension. + * + * @param extensionId Id of extension resource. + * @param farmBeatsResourceName FarmBeats resource name. + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + Response deleteWithResponse( + String extensionId, String farmBeatsResourceName, String resourceGroupName, Context context); + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + PagedIterable listByFarmBeats(String resourceGroupName, String farmBeatsResourceName); + + /** + * Get installed extensions details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param extensionId Id of extension resource. + * @param extensionCategory Category of extension (weather/sensor/satellite etc.). + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return installed extensions details. + */ + PagedIterable listByFarmBeats( + String resourceGroupName, + String farmBeatsResourceName, + String extensionId, + String extensionCategory, + Integer maxPageSize, + String skipToken, + Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeats.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeats.java new file mode 100644 index 000000000000..95c148bb7edb --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeats.java @@ -0,0 +1,214 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.agfood.fluent.models.FarmBeatsInner; +import java.util.Map; + +/** An immutable client-side representation of FarmBeats. */ +public interface FarmBeats { + /** + * Gets the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + String id(); + + /** + * Gets the name property: The name of the resource. + * + * @return the name value. + */ + String name(); + + /** + * Gets the type property: The type of the resource. + * + * @return the type value. + */ + String type(); + + /** + * Gets the location property: The geo-location where the resource lives. + * + * @return the location value. + */ + String location(); + + /** + * Gets the tags property: Resource tags. + * + * @return the tags value. + */ + Map tags(); + + /** + * Gets the systemData property: Metadata pertaining to creation and last modification of the resource. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the instanceUri property: Uri of the FarmBeats instance. + * + * @return the instanceUri value. + */ + String instanceUri(); + + /** + * Gets the provisioningState property: FarmBeats instance provisioning state. + * + * @return the provisioningState value. + */ + ProvisioningState provisioningState(); + + /** + * Gets the region of the resource. + * + * @return the region of the resource. + */ + Region region(); + + /** + * Gets the name of the resource region. + * + * @return the name of the resource region. + */ + String regionName(); + + /** + * Gets the inner com.azure.resourcemanager.agfood.fluent.models.FarmBeatsInner object. + * + * @return the inner object. + */ + FarmBeatsInner innerModel(); + + /** The entirety of the FarmBeats definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + /** The FarmBeats definition stages. */ + interface DefinitionStages { + /** The first stage of the FarmBeats definition. */ + interface Blank extends WithLocation { + } + /** The stage of the FarmBeats definition allowing to specify location. */ + interface WithLocation { + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(Region location); + + /** + * Specifies the region for the resource. + * + * @param location The geo-location where the resource lives. + * @return the next definition stage. + */ + WithResourceGroup withRegion(String location); + } + /** The stage of the FarmBeats definition allowing to specify parent resource. */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + /** + * The stage of the FarmBeats definition which contains all the minimum required properties for the resource to + * be created, but also allows for any other optional properties to be specified. + */ + interface WithCreate extends DefinitionStages.WithTags { + /** + * Executes the create request. + * + * @return the created resource. + */ + FarmBeats create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + FarmBeats create(Context context); + } + /** The stage of the FarmBeats definition allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + WithCreate withTags(Map tags); + } + } + /** + * Begins update for the FarmBeats resource. + * + * @return the stage of resource update. + */ + FarmBeats.Update update(); + + /** The template for FarmBeats update. */ + interface Update extends UpdateStages.WithTags { + /** + * Executes the update request. + * + * @return the updated resource. + */ + FarmBeats apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + FarmBeats apply(Context context); + } + /** The FarmBeats update stages. */ + interface UpdateStages { + /** The stage of the FarmBeats update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + FarmBeats refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + FarmBeats refresh(Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsListResponse.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsListResponse.java new file mode 100644 index 000000000000..9cfd0710b366 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsListResponse.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.models.FarmBeatsInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Paged response contains list of requested objects and a URL link to get the next set of results. */ +@Fluent +public final class FarmBeatsListResponse { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FarmBeatsListResponse.class); + + /* + * List of requested objects. + */ + @JsonProperty(value = "value") + private List value; + + /* + * Continuation link (absolute URI) to the next page of results in the + * list. + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: List of requested objects. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of requested objects. + * + * @param value the value value to set. + * @return the FarmBeatsListResponse object itself. + */ + public FarmBeatsListResponse withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: Continuation link (absolute URI) to the next page of results in the list. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsModels.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsModels.java new file mode 100644 index 000000000000..0ca4b6273da7 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsModels.java @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of FarmBeatsModels. */ +public interface FarmBeatsModels { + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + FarmBeats getByResourceGroup(String resourceGroupName, String farmBeatsResourceName); + + /** + * Get FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String farmBeatsResourceName, Context context); + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String farmBeatsResourceName); + + /** + * Delete a FarmBeats resource. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param farmBeatsResourceName FarmBeats resource name. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + Response deleteWithResponse(String resourceGroupName, String farmBeatsResourceName, Context context); + + /** + * Lists the FarmBeats instances for a subscription. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + PagedIterable list(); + + /** + * Lists the FarmBeats instances for a subscription. + * + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Skip token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + PagedIterable list(Integer maxPageSize, String skipToken, Context context); + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists the FarmBeats instances for a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param maxPageSize Maximum number of items needed (inclusive). Minimum = 10, Maximum = 1000, Default value = 50. + * @param skipToken Continuation token for getting next set of results. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return paged response contains list of requested objects and a URL link to get the next set of results. + */ + PagedIterable listByResourceGroup( + String resourceGroupName, Integer maxPageSize, String skipToken, Context context); + + /** + * Get FarmBeats resource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + FarmBeats getById(String id); + + /** + * Get FarmBeats resource. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return farmBeats resource. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a FarmBeats resource. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a FarmBeats resource. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new FarmBeats resource. + * + * @param name resource name. + * @return the first stage of the new FarmBeats definition. + */ + FarmBeats.DefinitionStages.Blank define(String name); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsUpdateRequestModel.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsUpdateRequestModel.java new file mode 100644 index 000000000000..d6a244bc7294 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/FarmBeatsUpdateRequestModel.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** FarmBeats update request. */ +@Fluent +public final class FarmBeatsUpdateRequestModel { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FarmBeatsUpdateRequestModel.class); + + /* + * Resource tags. + */ + @JsonProperty(value = "tags") + private Map tags; + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the FarmBeatsUpdateRequestModel object itself. + */ + public FarmBeatsUpdateRequestModel withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Locations.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Locations.java new file mode 100644 index 000000000000..c743303191ab --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Locations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of Locations. */ +public interface Locations { + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + CheckNameAvailabilityResponse checkNameAvailability(CheckNameAvailabilityRequest body); + + /** + * Checks the name availability of the resource with requested resource name. + * + * @param body NameAvailabilityRequest object. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the check availability result. + */ + Response checkNameAvailabilityWithResponse( + CheckNameAvailabilityRequest body, Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Operation.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Operation.java new file mode 100644 index 000000000000..824f1a543e8d --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Operation.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.resourcemanager.agfood.fluent.models.OperationInner; + +/** An immutable client-side representation of Operation. */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for ARM/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Enum. Indicates the action type. "Internal" refers to actions that are for internal + * only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.agfood.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/OperationDisplay.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/OperationDisplay.java new file mode 100644 index 000000000000..e51ea271ab56 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/OperationDisplay.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Localized display information for this particular operation. */ +@Immutable +public final class OperationDisplay { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationDisplay.class); + + /* + * The localized friendly form of the resource provider name, e.g. + * "Microsoft Monitoring Insights" or "Microsoft Compute". + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private String provider; + + /* + * The localized friendly name of the resource type related to this + * operation. E.g. "Virtual Machines" or "Job Schedule Collections". + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for + * dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual + * Machine". + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for + * tool tips and detailed views. + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/OperationListResult.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/OperationListResult.java new file mode 100644 index 000000000000..d4a8bf002b38 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/OperationListResult.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.agfood.fluent.models.OperationInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationListResult.class); + + /* + * List of operations supported by the resource provider + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private List value; + + /* + * URL to get the next set of operation list results (if there are any). + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: List of operations supported by the resource provider. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: URL to get the next set of operation list results (if there are any). + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Operations.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Operations.java new file mode 100644 index 000000000000..dd321a550875 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Operations.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + PagedIterable list(); + + /** + * Lists the available operations of Microsoft.AgFoodPlatform resource provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider. + */ + PagedIterable list(Context context); +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Origin.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Origin.java new file mode 100644 index 000000000000..08656378997d --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/Origin.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for Origin. */ +public final class Origin extends ExpandableStringEnum { + /** Static value user for Origin. */ + public static final Origin USER = fromString("user"); + + /** Static value system for Origin. */ + public static final Origin SYSTEM = fromString("system"); + + /** Static value user,system for Origin. */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + @JsonCreator + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** @return known Origin values. */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ProvisioningState.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ProvisioningState.java new file mode 100644 index 000000000000..e3b11427c89f --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/ProvisioningState.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.agfood.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for ProvisioningState. */ +public final class ProvisioningState extends ExpandableStringEnum { + /** Static value Succeeded for ProvisioningState. */ + public static final ProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** Static value Failed for ProvisioningState. */ + public static final ProvisioningState FAILED = fromString("Failed"); + + /** + * Creates or finds a ProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ProvisioningState. + */ + @JsonCreator + public static ProvisioningState fromString(String name) { + return fromString(name, ProvisioningState.class); + } + + /** @return known ProvisioningState values. */ + public static Collection values() { + return values(ProvisioningState.class); + } +} diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/package-info.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/package-info.java new file mode 100644 index 000000000000..9fce43ab966a --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/models/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the data models for AzureAgFoodPlatformRPService. APIs documentation for Azure AgFoodPlatform + * Resource Provider Service. + */ +package com.azure.resourcemanager.agfood.models; diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/package-info.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/package-info.java new file mode 100644 index 000000000000..79d7628e11a7 --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/com/azure/resourcemanager/agfood/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * Package containing the classes for AzureAgFoodPlatformRPService. APIs documentation for Azure AgFoodPlatform Resource + * Provider Service. + */ +package com.azure.resourcemanager.agfood; diff --git a/sdk/agfood/azure-resourcemanager-agfood/src/main/java/module-info.java b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/module-info.java new file mode 100644 index 000000000000..929db88ad27c --- /dev/null +++ b/sdk/agfood/azure-resourcemanager-agfood/src/main/java/module-info.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.agfood { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.agfood; + exports com.azure.resourcemanager.agfood.fluent; + exports com.azure.resourcemanager.agfood.fluent.models; + exports com.azure.resourcemanager.agfood.models; + + opens com.azure.resourcemanager.agfood.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.agfood.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/agfood/ci.yml b/sdk/agfood/ci.yml new file mode 100644 index 000000000000..cda1b8856158 --- /dev/null +++ b/sdk/agfood/ci.yml @@ -0,0 +1,33 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - main + - hotfix/* + - release/* + paths: + include: + - sdk/agfood/ + +pr: + branches: + include: + - master + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/agfood/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: agfood + Artifacts: + - name: azure-resourcemanager-agfood + groupId: com.azure.resourcemanager + safeName: azureresourcemanageragfood diff --git a/sdk/agfood/pom.xml b/sdk/agfood/pom.xml new file mode 100644 index 000000000000..1dc03a749039 --- /dev/null +++ b/sdk/agfood/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-agfood-service + pom + 1.0.0 + + + + coverage + + + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + report-aggregate + verify + + report-aggregate + + + ${project.reporting.outputDirectory}/test-coverage + + + + + + + + + default + + true + + + azure-resourcemanager-agfood + + + +