diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 76448943a049a..0016b28fb95f5 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -340,6 +340,7 @@ com.azure.resourcemanager:azure-resourcemanager-securityinsights;1.0.0-beta.2;1. com.azure.resourcemanager:azure-resourcemanager-oep;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-dnsresolver;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-mobilenetwork;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-windowsiot;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.0.0 com.azure.tools:azure-sdk-build-tool;1.0.0-beta.1;1.0.0-beta.2 diff --git a/pom.xml b/pom.xml index f3ba561857a58..165b7a30588a5 100644 --- a/pom.xml +++ b/pom.xml @@ -978,6 +978,7 @@ sdk/videoanalyzer sdk/vmwarecloudsimple sdk/webpubsub + sdk/windowsiot diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/CHANGELOG.md b/sdk/windowsiot/azure-resourcemanager-windowsiot/CHANGELOG.md new file mode 100644 index 0000000000000..3d37b3a0390ad --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2022-03-24) + +- Azure Resource Manager windowsiot client library for Java. This package contains Microsoft Azure SDK for windowsiot Management SDK. Use this API to manage the Windows IoT device services in your Azure subscription. Package tag package-2019-06. 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/windowsiot/azure-resourcemanager-windowsiot/README.md b/sdk/windowsiot/azure-resourcemanager-windowsiot/README.md new file mode 100644 index 0000000000000..b4c98db476d5f --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager windowsiot client library for Java + +Azure Resource Manager windowsiot client library for Java. + +This package contains Microsoft Azure SDK for windowsiot Management SDK. Use this API to manage the Windows IoT device services in your Azure subscription. Package tag package-2019-06. 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-windowsiot;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-windowsiot + 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(); +WindowsiotManager manager = WindowsiotManager + .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 + +[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/windowsiot/azure-resourcemanager-windowsiot/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/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/main/sdk/identity/azure-identity +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/SAMPLE.md b/sdk/windowsiot/azure-resourcemanager-windowsiot/SAMPLE.md new file mode 100644 index 0000000000000..a916ba18f2205 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/SAMPLE.md @@ -0,0 +1,204 @@ +# Code snippets and samples + + +## Operations + +- [List](#operations_list) + +## Services + +- [CheckDeviceServiceNameAvailability](#services_checkdeviceservicenameavailability) +- [CreateOrUpdate](#services_createorupdate) +- [Delete](#services_delete) +- [GetByResourceGroup](#services_getbyresourcegroup) +- [List](#services_list) +- [ListByResourceGroup](#services_listbyresourcegroup) +- [Update](#services_update) +### Operations_List + +```java +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/OperationsList.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void operationsList(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.operations().list(Context.NONE); + } +} +``` + +### Services_CheckDeviceServiceNameAvailability + +```java +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceCheckNameAvailabilityParameters; + +/** Samples for Services CheckDeviceServiceNameAvailability. */ +public final class ServicesCheckDeviceServiceNameAvailabilitySamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_CheckNameAvailability.json + */ + /** + * Sample code: Service_CheckNameAvailability. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceCheckNameAvailability(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager + .services() + .checkDeviceServiceNameAvailabilityWithResponse( + new DeviceServiceCheckNameAvailabilityParameters().withName("service3363"), Context.NONE); + } +} +``` + +### Services_CreateOrUpdate + +```java +/** Samples for Services CreateOrUpdate. */ +public final class ServicesCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Create.json + */ + /** + * Sample code: Service_Create. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceCreate(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager + .services() + .define("service4445") + .withRegion("East US") + .withExistingResourceGroup("res9101") + .withNotes("blah") + .withQuantity(1000000L) + .withBillingDomainName("a.b.c") + .withAdminDomainName("d.e.f") + .create(); + } +} +``` + +### Services_Delete + +```java +import com.azure.core.util.Context; + +/** Samples for Services Delete. */ +public final class ServicesDeleteSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Delete.json + */ + /** + * Sample code: Service_Delete. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceDelete(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().deleteWithResponse("res4228", "service2434", Context.NONE); + } +} +``` + +### Services_GetByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for Services GetByResourceGroup. */ +public final class ServicesGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_GetProperties.json + */ + /** + * Sample code: Services_GetProperties. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void servicesGetProperties(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().getByResourceGroupWithResponse("res9407", "service8596", Context.NONE); + } +} +``` + +### Services_List + +```java +import com.azure.core.util.Context; + +/** Samples for Services List. */ +public final class ServicesListSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_List.json + */ + /** + * Sample code: Service_List. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceList(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().list(Context.NONE); + } +} +``` + +### Services_ListByResourceGroup + +```java +import com.azure.core.util.Context; + +/** Samples for Services ListByResourceGroup. */ +public final class ServicesListByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_ListByResourceGroup.json + */ + /** + * Sample code: Service_ListByResourceGroup. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceListByResourceGroup(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().listByResourceGroup("res6117", Context.NONE); + } +} +``` + +### Services_Update + +```java +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsiot.models.DeviceService; + +/** Samples for Services Update. */ +public final class ServicesUpdateSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Update.json + */ + /** + * Sample code: Service_Update. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceUpdate(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + DeviceService resource = + manager.services().getByResourceGroupWithResponse("res9407", "service8596", Context.NONE).getValue(); + resource + .update() + .withNotes("blah") + .withQuantity(1000000L) + .withBillingDomainName("a.b.c") + .withAdminDomainName("d.e.f") + .apply(); + } +} +``` + diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/pom.xml b/sdk/windowsiot/azure-resourcemanager-windowsiot/pom.xml new file mode 100644 index 0000000000000..12cd2d21ee36d --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/pom.xml @@ -0,0 +1,55 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-windowsiot + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for windowsiot Management + This package contains Microsoft Azure SDK for windowsiot Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Use this API to manage the Windows IoT device services in your Azure subscription. Package tag package-2019-06. + 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 + true + + + + com.azure + azure-core + 1.26.0 + + + com.azure + azure-core-management + 1.5.3 + + + diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/WindowsiotManager.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/WindowsiotManager.java new file mode 100644 index 0000000000000..55456db266e49 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/WindowsiotManager.java @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot; + +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.HttpPipelinePosition; +import com.azure.core.http.policy.AddDatePolicy; +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.http.policy.ArmChallengeAuthenticationPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.windowsiot.fluent.DeviceServices; +import com.azure.resourcemanager.windowsiot.implementation.DeviceServicesBuilder; +import com.azure.resourcemanager.windowsiot.implementation.OperationsImpl; +import com.azure.resourcemanager.windowsiot.implementation.ServicesImpl; +import com.azure.resourcemanager.windowsiot.models.Operations; +import com.azure.resourcemanager.windowsiot.models.Services; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to WindowsiotManager. Use this API to manage the Windows IoT device services in your Azure subscription. + */ +public final class WindowsiotManager { + private Operations operations; + + private Services services; + + private final DeviceServices clientObject; + + private WindowsiotManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new DeviceServicesBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of windowsiot service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the windowsiot service API instance. + */ + public static WindowsiotManager 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 WindowsiotManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new WindowsiotManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private final List scopes = 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; + } + + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' 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, "'defaultPollInterval' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of windowsiot service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the windowsiot service API instance. + */ + public WindowsiotManager 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.windowsiot") + .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 (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } + if (retryPolicy == null) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new RequestIdPolicy()); + policies + .addAll( + this + .policies + .stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL) + .collect(Collectors.toList())); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); + policies + .addAll( + this + .policies + .stream() + .filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY) + .collect(Collectors.toList())); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new WindowsiotManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of Operations. */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** @return Resource collection API of Services. */ + public Services services() { + if (this.services == null) { + this.services = new ServicesImpl(clientObject.getServices(), this); + } + return services; + } + + /** + * @return Wrapped service client DeviceServices providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + */ + public DeviceServices serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/DeviceServices.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/DeviceServices.java new file mode 100644 index 0000000000000..c36a26a43aa02 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/DeviceServices.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for DeviceServices class. */ +public interface DeviceServices { + /** + * Gets The subscription identifier. + * + * @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 OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the ServicesClient object to access its operations. + * + * @return the ServicesClient object. + */ + ServicesClient getServices(); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/OperationsClient.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/OperationsClient.java new file mode 100644 index 0000000000000..557228398f69b --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/OperationsClient.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.windowsiot.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.windowsiot.fluent.models.OperationEntityInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * Lists all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/ServicesClient.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/ServicesClient.java new file mode 100644 index 0000000000000..27d419dd70719 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/ServicesClient.java @@ -0,0 +1,223 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.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.windowsiot.fluent.models.DeviceServiceInner; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceNameAvailabilityInfoInner; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceCheckNameAvailabilityParameters; + +/** An instance of this class provides access to all the operations defined in ServicesClient. */ +public interface ServicesClient { + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeviceServiceInner getByResourceGroup(String resourceGroupName, String deviceName); + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String deviceName, Context context); + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @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 description of the Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeviceServiceInner createOrUpdate(String resourceGroupName, String deviceName, DeviceServiceInner deviceService); + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService, String ifMatch, Context context); + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @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 description of the Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeviceServiceInner update(String resourceGroupName, String deviceName, DeviceServiceInner deviceService); + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a brand new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService, String ifMatch, Context context); + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeviceServiceInner delete(String resourceGroupName, String deviceName); + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String deviceName, Context context); + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get all the IoT hubs in 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 all the IoT hubs in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Get all the IoT hubs in a subscription. + * + * @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 all the IoT hubs in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + DeviceServiceNameAvailabilityInfoInner checkDeviceServiceNameAvailability( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters); + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available along with {@link + * Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response checkDeviceServiceNameAvailabilityWithResponse( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters, Context context); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceInner.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceInner.java new file mode 100644 index 0000000000000..d108ee63cedb9 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceInner.java @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; +import java.util.Map; + +/** The description of the Windows IoT Device Service. */ +@Fluent +public final class DeviceServiceInner extends Resource { + /* + * The Etag field is *not* required. If it is provided in the response + * body, it must also be provided as a header per the normal ETag + * convention. + */ + @JsonProperty(value = "etag") + private String etag; + + /* + * The properties of a Windows IoT Device Service. + */ + @JsonProperty(value = "properties") + private DeviceServiceProperties innerProperties; + + /** + * Get the etag property: The Etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal ETag convention. + * + * @return the etag value. + */ + public String etag() { + return this.etag; + } + + /** + * Set the etag property: The Etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal ETag convention. + * + * @param etag the etag value to set. + * @return the DeviceServiceInner object itself. + */ + public DeviceServiceInner withEtag(String etag) { + this.etag = etag; + return this; + } + + /** + * Get the innerProperties property: The properties of a Windows IoT Device Service. + * + * @return the innerProperties value. + */ + private DeviceServiceProperties innerProperties() { + return this.innerProperties; + } + + /** {@inheritDoc} */ + @Override + public DeviceServiceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public DeviceServiceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Get the notes property: Windows IoT Device Service notes. + * + * @return the notes value. + */ + public String notes() { + return this.innerProperties() == null ? null : this.innerProperties().notes(); + } + + /** + * Set the notes property: Windows IoT Device Service notes. + * + * @param notes the notes value to set. + * @return the DeviceServiceInner object itself. + */ + public DeviceServiceInner withNotes(String notes) { + if (this.innerProperties() == null) { + this.innerProperties = new DeviceServiceProperties(); + } + this.innerProperties().withNotes(notes); + return this; + } + + /** + * Get the startDate property: Windows IoT Device Service start date,. + * + * @return the startDate value. + */ + public OffsetDateTime startDate() { + return this.innerProperties() == null ? null : this.innerProperties().startDate(); + } + + /** + * Get the quantity property: Windows IoT Device Service device allocation,. + * + * @return the quantity value. + */ + public Long quantity() { + return this.innerProperties() == null ? null : this.innerProperties().quantity(); + } + + /** + * Set the quantity property: Windows IoT Device Service device allocation,. + * + * @param quantity the quantity value to set. + * @return the DeviceServiceInner object itself. + */ + public DeviceServiceInner withQuantity(Long quantity) { + if (this.innerProperties() == null) { + this.innerProperties = new DeviceServiceProperties(); + } + this.innerProperties().withQuantity(quantity); + return this; + } + + /** + * Get the billingDomainName property: Windows IoT Device Service ODM AAD domain. + * + * @return the billingDomainName value. + */ + public String billingDomainName() { + return this.innerProperties() == null ? null : this.innerProperties().billingDomainName(); + } + + /** + * Set the billingDomainName property: Windows IoT Device Service ODM AAD domain. + * + * @param billingDomainName the billingDomainName value to set. + * @return the DeviceServiceInner object itself. + */ + public DeviceServiceInner withBillingDomainName(String billingDomainName) { + if (this.innerProperties() == null) { + this.innerProperties = new DeviceServiceProperties(); + } + this.innerProperties().withBillingDomainName(billingDomainName); + return this; + } + + /** + * Get the adminDomainName property: Windows IoT Device Service OEM AAD domain. + * + * @return the adminDomainName value. + */ + public String adminDomainName() { + return this.innerProperties() == null ? null : this.innerProperties().adminDomainName(); + } + + /** + * Set the adminDomainName property: Windows IoT Device Service OEM AAD domain. + * + * @param adminDomainName the adminDomainName value to set. + * @return the DeviceServiceInner object itself. + */ + public DeviceServiceInner withAdminDomainName(String adminDomainName) { + if (this.innerProperties() == null) { + this.innerProperties = new DeviceServiceProperties(); + } + this.innerProperties().withAdminDomainName(adminDomainName); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (innerProperties() != null) { + innerProperties().validate(); + } + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceNameAvailabilityInfoInner.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceNameAvailabilityInfoInner.java new file mode 100644 index 0000000000000..c711d32c9cf92 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceNameAvailabilityInfoInner.java @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.windowsiot.models.ServiceNameUnavailabilityReason; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The properties indicating whether a given Windows IoT Device Service name is available. */ +@Fluent +public final class DeviceServiceNameAvailabilityInfoInner { + /* + * The value which indicates whether the provided name is available. + */ + @JsonProperty(value = "nameAvailable", access = JsonProperty.Access.WRITE_ONLY) + private Boolean nameAvailable; + + /* + * The reason for unavailability. + */ + @JsonProperty(value = "reason", access = JsonProperty.Access.WRITE_ONLY) + private ServiceNameUnavailabilityReason reason; + + /* + * The detailed reason message. + */ + @JsonProperty(value = "message") + private String message; + + /** + * Get the nameAvailable property: The value which indicates whether the provided name is available. + * + * @return the nameAvailable value. + */ + public Boolean nameAvailable() { + return this.nameAvailable; + } + + /** + * Get the reason property: The reason for unavailability. + * + * @return the reason value. + */ + public ServiceNameUnavailabilityReason reason() { + return this.reason; + } + + /** + * Get the message property: The detailed reason message. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * Set the message property: The detailed reason message. + * + * @param message the message value to set. + * @return the DeviceServiceNameAvailabilityInfoInner object itself. + */ + public DeviceServiceNameAvailabilityInfoInner 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/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceProperties.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceProperties.java new file mode 100644 index 0000000000000..83156e5b3cfc5 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/DeviceServiceProperties.java @@ -0,0 +1,140 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** The properties of a Windows IoT Device Service. */ +@Fluent +public final class DeviceServiceProperties { + /* + * Windows IoT Device Service notes. + */ + @JsonProperty(value = "notes") + private String notes; + + /* + * Windows IoT Device Service start date, + */ + @JsonProperty(value = "startDate", access = JsonProperty.Access.WRITE_ONLY) + private OffsetDateTime startDate; + + /* + * Windows IoT Device Service device allocation, + */ + @JsonProperty(value = "quantity") + private Long quantity; + + /* + * Windows IoT Device Service ODM AAD domain + */ + @JsonProperty(value = "billingDomainName") + private String billingDomainName; + + /* + * Windows IoT Device Service OEM AAD domain + */ + @JsonProperty(value = "adminDomainName") + private String adminDomainName; + + /** + * Get the notes property: Windows IoT Device Service notes. + * + * @return the notes value. + */ + public String notes() { + return this.notes; + } + + /** + * Set the notes property: Windows IoT Device Service notes. + * + * @param notes the notes value to set. + * @return the DeviceServiceProperties object itself. + */ + public DeviceServiceProperties withNotes(String notes) { + this.notes = notes; + return this; + } + + /** + * Get the startDate property: Windows IoT Device Service start date,. + * + * @return the startDate value. + */ + public OffsetDateTime startDate() { + return this.startDate; + } + + /** + * Get the quantity property: Windows IoT Device Service device allocation,. + * + * @return the quantity value. + */ + public Long quantity() { + return this.quantity; + } + + /** + * Set the quantity property: Windows IoT Device Service device allocation,. + * + * @param quantity the quantity value to set. + * @return the DeviceServiceProperties object itself. + */ + public DeviceServiceProperties withQuantity(Long quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get the billingDomainName property: Windows IoT Device Service ODM AAD domain. + * + * @return the billingDomainName value. + */ + public String billingDomainName() { + return this.billingDomainName; + } + + /** + * Set the billingDomainName property: Windows IoT Device Service ODM AAD domain. + * + * @param billingDomainName the billingDomainName value to set. + * @return the DeviceServiceProperties object itself. + */ + public DeviceServiceProperties withBillingDomainName(String billingDomainName) { + this.billingDomainName = billingDomainName; + return this; + } + + /** + * Get the adminDomainName property: Windows IoT Device Service OEM AAD domain. + * + * @return the adminDomainName value. + */ + public String adminDomainName() { + return this.adminDomainName; + } + + /** + * Set the adminDomainName property: Windows IoT Device Service OEM AAD domain. + * + * @param adminDomainName the adminDomainName value to set. + * @return the DeviceServiceProperties object itself. + */ + public DeviceServiceProperties withAdminDomainName(String adminDomainName) { + this.adminDomainName = adminDomainName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/OperationEntityInner.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/OperationEntityInner.java new file mode 100644 index 0000000000000..4f71b44fafa0a --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/OperationEntityInner.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.windowsiot.models.OperationDisplayInfo; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The operation supported by Azure Data Catalog Service. */ +@Fluent +public final class OperationEntityInner { + /* + * Operation name: {provider}/{resource}/{operation}. + */ + @JsonProperty(value = "name") + private String name; + + /* + * The operation supported by Azure Data Catalog Service. + */ + @JsonProperty(value = "display") + private OperationDisplayInfo display; + + /* + * Indicates whether the operation is a data action + */ + @JsonProperty(value = "isDataAction") + private Boolean isDataAction; + + /* + * Indicates the executor of the operation. + */ + @JsonProperty(value = "origin") + private String origin; + + /** + * Get the name property: Operation name: {provider}/{resource}/{operation}. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Operation name: {provider}/{resource}/{operation}. + * + * @param name the name value to set. + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the display property: The operation supported by Azure Data Catalog Service. + * + * @return the display value. + */ + public OperationDisplayInfo display() { + return this.display; + } + + /** + * Set the display property: The operation supported by Azure Data Catalog Service. + * + * @param display the display value to set. + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withDisplay(OperationDisplayInfo display) { + this.display = display; + return this; + } + + /** + * Get the isDataAction property: Indicates whether the operation is a data action. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Set the isDataAction property: Indicates whether the operation is a data action. + * + * @param isDataAction the isDataAction value to set. + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withIsDataAction(Boolean isDataAction) { + this.isDataAction = isDataAction; + return this; + } + + /** + * Get the origin property: Indicates the executor of the operation. + * + * @return the origin value. + */ + public String origin() { + return this.origin; + } + + /** + * Set the origin property: Indicates the executor of the operation. + * + * @param origin the origin value to set. + * @return the OperationEntityInner object itself. + */ + public OperationEntityInner withOrigin(String origin) { + this.origin = origin; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/package-info.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/models/package-info.java new file mode 100644 index 0000000000000..dccb06d6f4ea5 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/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 DeviceServices. Use this API to manage the Windows IoT device services + * in your Azure subscription. + */ +package com.azure.resourcemanager.windowsiot.fluent.models; diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/package-info.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/fluent/package-info.java new file mode 100644 index 0000000000000..5eb9851412ba1 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/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 DeviceServices. Use this API to manage the Windows IoT device services in + * your Azure subscription. + */ +package com.azure.resourcemanager.windowsiot.fluent; diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServiceImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServiceImpl.java new file mode 100644 index 0000000000000..0b83b99e8c06f --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServiceImpl.java @@ -0,0 +1,232 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.implementation; + +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceInner; +import com.azure.resourcemanager.windowsiot.models.DeviceService; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.Map; + +public final class DeviceServiceImpl implements DeviceService, DeviceService.Definition, DeviceService.Update { + private DeviceServiceInner innerObject; + + private final com.azure.resourcemanager.windowsiot.WindowsiotManager 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 String etag() { + return this.innerModel().etag(); + } + + public String notes() { + return this.innerModel().notes(); + } + + public OffsetDateTime startDate() { + return this.innerModel().startDate(); + } + + public Long quantity() { + return this.innerModel().quantity(); + } + + public String billingDomainName() { + return this.innerModel().billingDomainName(); + } + + public String adminDomainName() { + return this.innerModel().adminDomainName(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public DeviceServiceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.windowsiot.WindowsiotManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String deviceName; + + private String createIfMatch; + + private String updateIfMatch; + + public DeviceServiceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public DeviceService create() { + this.innerObject = + serviceManager + .serviceClient() + .getServices() + .createOrUpdateWithResponse( + resourceGroupName, deviceName, this.innerModel(), createIfMatch, Context.NONE) + .getValue(); + return this; + } + + public DeviceService create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getServices() + .createOrUpdateWithResponse(resourceGroupName, deviceName, this.innerModel(), createIfMatch, context) + .getValue(); + return this; + } + + DeviceServiceImpl(String name, com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager) { + this.innerObject = new DeviceServiceInner(); + this.serviceManager = serviceManager; + this.deviceName = name; + this.createIfMatch = null; + } + + public DeviceServiceImpl update() { + this.updateIfMatch = null; + return this; + } + + public DeviceService apply() { + this.innerObject = + serviceManager + .serviceClient() + .getServices() + .updateWithResponse(resourceGroupName, deviceName, this.innerModel(), updateIfMatch, Context.NONE) + .getValue(); + return this; + } + + public DeviceService apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getServices() + .updateWithResponse(resourceGroupName, deviceName, this.innerModel(), updateIfMatch, context) + .getValue(); + return this; + } + + DeviceServiceImpl( + DeviceServiceInner innerObject, com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.deviceName = Utils.getValueFromIdByName(innerObject.id(), "deviceServices"); + } + + public DeviceService refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getServices() + .getByResourceGroupWithResponse(resourceGroupName, deviceName, Context.NONE) + .getValue(); + return this; + } + + public DeviceService refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getServices() + .getByResourceGroupWithResponse(resourceGroupName, deviceName, context) + .getValue(); + return this; + } + + public DeviceServiceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public DeviceServiceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public DeviceServiceImpl withTags(Map tags) { + this.innerModel().withTags(tags); + return this; + } + + public DeviceServiceImpl withEtag(String etag) { + this.innerModel().withEtag(etag); + return this; + } + + public DeviceServiceImpl withNotes(String notes) { + this.innerModel().withNotes(notes); + return this; + } + + public DeviceServiceImpl withQuantity(Long quantity) { + this.innerModel().withQuantity(quantity); + return this; + } + + public DeviceServiceImpl withBillingDomainName(String billingDomainName) { + this.innerModel().withBillingDomainName(billingDomainName); + return this; + } + + public DeviceServiceImpl withAdminDomainName(String adminDomainName) { + this.innerModel().withAdminDomainName(adminDomainName); + return this; + } + + public DeviceServiceImpl withIfMatch(String ifMatch) { + if (isInCreateMode()) { + this.createIfMatch = ifMatch; + return this; + } else { + this.updateIfMatch = ifMatch; + return this; + } + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServiceNameAvailabilityInfoImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServiceNameAvailabilityInfoImpl.java new file mode 100644 index 0000000000000..94b45752a970f --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServiceNameAvailabilityInfoImpl.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.implementation; + +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceNameAvailabilityInfoInner; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceNameAvailabilityInfo; +import com.azure.resourcemanager.windowsiot.models.ServiceNameUnavailabilityReason; + +public final class DeviceServiceNameAvailabilityInfoImpl implements DeviceServiceNameAvailabilityInfo { + private DeviceServiceNameAvailabilityInfoInner innerObject; + + private final com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager; + + DeviceServiceNameAvailabilityInfoImpl( + DeviceServiceNameAvailabilityInfoInner innerObject, + com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public Boolean nameAvailable() { + return this.innerModel().nameAvailable(); + } + + public ServiceNameUnavailabilityReason reason() { + return this.innerModel().reason(); + } + + public String message() { + return this.innerModel().message(); + } + + public DeviceServiceNameAvailabilityInfoInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.windowsiot.WindowsiotManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServicesBuilder.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServicesBuilder.java new file mode 100644 index 0000000000000..6a0d96dea13a6 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServicesBuilder.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.windowsiot.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 DeviceServicesImpl type. */ +@ServiceClientBuilder(serviceClients = {DeviceServicesImpl.class}) +public final class DeviceServicesBuilder { + /* + * The subscription identifier. + */ + private String subscriptionId; + + /** + * Sets The subscription identifier. + * + * @param subscriptionId the subscriptionId value. + * @return the DeviceServicesBuilder. + */ + public DeviceServicesBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the DeviceServicesBuilder. + */ + public DeviceServicesBuilder 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 DeviceServicesBuilder. + */ + public DeviceServicesBuilder 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 DeviceServicesBuilder. + */ + public DeviceServicesBuilder 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 DeviceServicesBuilder. + */ + public DeviceServicesBuilder 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 DeviceServicesBuilder. + */ + public DeviceServicesBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of DeviceServicesImpl with the provided parameters. + * + * @return an instance of DeviceServicesImpl. + */ + public DeviceServicesImpl 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(); + } + DeviceServicesImpl client = + new DeviceServicesImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServicesImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServicesImpl.java new file mode 100644 index 0000000000000..39d92bd8d639c --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/DeviceServicesImpl.java @@ -0,0 +1,307 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.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.windowsiot.fluent.DeviceServices; +import com.azure.resourcemanager.windowsiot.fluent.OperationsClient; +import com.azure.resourcemanager.windowsiot.fluent.ServicesClient; +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 DeviceServicesImpl type. */ +@ServiceClient(builder = DeviceServicesBuilder.class) +public final class DeviceServicesImpl implements DeviceServices { + /** The subscription identifier. */ + private final String subscriptionId; + + /** + * Gets The subscription identifier. + * + * @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 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; + } + + /** The ServicesClient object to access its operations. */ + private final ServicesClient services; + + /** + * Gets the ServicesClient object to access its operations. + * + * @return the ServicesClient object. + */ + public ServicesClient getServices() { + return this.services; + } + + /** + * Initializes an instance of DeviceServices 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 subscription identifier. + * @param endpoint server parameter. + */ + DeviceServicesImpl( + 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 = "2019-06-01"; + this.operations = new OperationsClientImpl(this); + this.services = new ServicesClientImpl(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)); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DeviceServicesImpl.class); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationEntityImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationEntityImpl.java new file mode 100644 index 0000000000000..6b4e1b76eedb7 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationEntityImpl.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.windowsiot.implementation; + +import com.azure.resourcemanager.windowsiot.fluent.models.OperationEntityInner; +import com.azure.resourcemanager.windowsiot.models.OperationDisplayInfo; +import com.azure.resourcemanager.windowsiot.models.OperationEntity; + +public final class OperationEntityImpl implements OperationEntity { + private OperationEntityInner innerObject; + + private final com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager; + + OperationEntityImpl( + OperationEntityInner innerObject, com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public OperationDisplayInfo display() { + return this.innerModel().display(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public String origin() { + return this.innerModel().origin(); + } + + public OperationEntityInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.windowsiot.WindowsiotManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationsClientImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationsClientImpl.java new file mode 100644 index 0000000000000..38971130ae46d --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationsClientImpl.java @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.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.resourcemanager.windowsiot.fluent.OperationsClient; +import com.azure.resourcemanager.windowsiot.fluent.models.OperationEntityInner; +import com.azure.resourcemanager.windowsiot.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 { + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final DeviceServicesImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(DeviceServicesImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DeviceServicesOperations to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "DeviceServicesOperat") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.WindowsIoT/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 all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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 all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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 all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Lists all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Lists all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedIterable}. + */ + @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 result of the request to list Windows IoT Device Service operations along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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 result of the request to list Windows IoT Device Service operations along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationsImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..75a2f287aa2ae --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/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.windowsiot.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.windowsiot.fluent.OperationsClient; +import com.azure.resourcemanager.windowsiot.fluent.models.OperationEntityInner; +import com.azure.resourcemanager.windowsiot.models.OperationEntity; +import com.azure.resourcemanager.windowsiot.models.Operations; + +public final class OperationsImpl implements Operations { + private static final ClientLogger LOGGER = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager; + + public OperationsImpl( + OperationsClient innerClient, com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new OperationEntityImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new OperationEntityImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.windowsiot.WindowsiotManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/ServicesClientImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/ServicesClientImpl.java new file mode 100644 index 0000000000000..374f6652e2864 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/ServicesClientImpl.java @@ -0,0 +1,1559 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.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.Post; +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.resourcemanager.windowsiot.fluent.ServicesClient; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceInner; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceNameAvailabilityInfoInner; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceCheckNameAvailabilityParameters; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceDescriptionListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in ServicesClient. */ +public final class ServicesClientImpl implements ServicesClient { + /** The proxy service used to perform REST calls. */ + private final ServicesService service; + + /** The service client containing this operation class. */ + private final DeviceServicesImpl client; + + /** + * Initializes an instance of ServicesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ServicesClientImpl(DeviceServicesImpl client) { + this.service = RestProxy.create(ServicesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for DeviceServicesServices to be used by the proxy service to perform + * REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "DeviceServicesServic") + private interface ServicesService { + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT" + + "/deviceServices/{deviceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("deviceName") String deviceName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT" + + "/deviceServices/{deviceName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("deviceName") String deviceName, + @HeaderParam("If-Match") String ifMatch, + @BodyParam("application/json") DeviceServiceInner deviceService, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT" + + "/deviceServices/{deviceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("deviceName") String deviceName, + @HeaderParam("If-Match") String ifMatch, + @BodyParam("application/json") DeviceServiceInner deviceService, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT" + + "/deviceServices/{deviceName}") + @ExpectedResponses({200, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("deviceName") String deviceName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.WindowsIoT" + + "/deviceServices") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/deviceServices") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Post("/subscriptions/{subscriptionId}/providers/Microsoft.WindowsIoT/checkDeviceServiceNameAvailability") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> checkDeviceServiceNameAvailability( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @BodyParam("application/json") + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters, + @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); + + @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); + } + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String deviceName) { + 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service along with {@link Response} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String deviceName, 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + accept, + context); + } + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String deviceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, deviceName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeviceServiceInner getByResourceGroup(String resourceGroupName, String deviceName) { + return getByResourceGroupAsync(resourceGroupName, deviceName).block(); + } + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String deviceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, deviceName, context).block(); + } + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService, String ifMatch) { + 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + if (deviceService == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceService is required and cannot be null.")); + } else { + deviceService.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + ifMatch, + deviceService, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync( + String resourceGroupName, + String deviceName, + DeviceServiceInner deviceService, + String ifMatch, + 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + if (deviceService == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceService is required and cannot be null.")); + } else { + deviceService.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + ifMatch, + deviceService, + accept, + context); + } + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService, String ifMatch) { + return createOrUpdateWithResponseAsync(resourceGroupName, deviceName, deviceService, ifMatch) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @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 description of the Windows IoT Device Service on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService) { + final String ifMatch = null; + return createOrUpdateWithResponseAsync(resourceGroupName, deviceName, deviceService, ifMatch) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @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 description of the Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeviceServiceInner createOrUpdate( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService) { + final String ifMatch = null; + return createOrUpdateAsync(resourceGroupName, deviceName, deviceService, ifMatch).block(); + } + + /** + * Create or update the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to + * retrieve the Windows IoT Device Service metadata and security metadata, and then combine them with the modified + * values in a new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse( + String resourceGroupName, + String deviceName, + DeviceServiceInner deviceService, + String ifMatch, + Context context) { + return createOrUpdateWithResponseAsync(resourceGroupName, deviceName, deviceService, ifMatch, context).block(); + } + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a brand new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService, String ifMatch) { + 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + if (deviceService == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceService is required and cannot be null.")); + } else { + deviceService.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + ifMatch, + deviceService, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a brand new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync( + String resourceGroupName, + String deviceName, + DeviceServiceInner deviceService, + String ifMatch, + 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + if (deviceService == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceService is required and cannot be null.")); + } else { + deviceService.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + ifMatch, + deviceService, + accept, + context); + } + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a brand new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService, String ifMatch) { + return updateWithResponseAsync(resourceGroupName, deviceName, deviceService, ifMatch) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @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 description of the Windows IoT Device Service on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String deviceName, DeviceServiceInner deviceService) { + final String ifMatch = null; + return updateWithResponseAsync(resourceGroupName, deviceName, deviceService, ifMatch) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @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 description of the Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeviceServiceInner update(String resourceGroupName, String deviceName, DeviceServiceInner deviceService) { + final String ifMatch = null; + return updateAsync(resourceGroupName, deviceName, deviceService, ifMatch).block(); + } + + /** + * Updates the metadata of a Windows IoT Device Service. The usual pattern to modify a property is to retrieve the + * Windows IoT Device Service metadata and security metadata, and then combine them with the modified values in a + * new body to update the Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @param deviceService The Windows IoT Device Service metadata and security metadata. + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a brand new Windows IoT Device + * Service. Required to update an existing Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse( + String resourceGroupName, + String deviceName, + DeviceServiceInner deviceService, + String ifMatch, + Context context) { + return updateWithResponseAsync(resourceGroupName, deviceName, deviceService, ifMatch, context).block(); + } + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String deviceName) { + 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync( + String resourceGroupName, String deviceName, 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (deviceName == null) { + return Mono.error(new IllegalArgumentException("Parameter deviceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + deviceName, + accept, + context); + } + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String deviceName) { + return deleteWithResponseAsync(resourceGroupName, deviceName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeviceServiceInner delete(String resourceGroupName, String deviceName) { + return deleteAsync(resourceGroupName, deviceName).block(); + } + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse( + String resourceGroupName, String deviceName, Context context) { + return deleteWithResponseAsync(resourceGroupName, deviceName, context).block(); + } + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group along with {@link PagedResponse} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync(String resourceGroupName) { + 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 (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + 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 all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group along with {@link PagedResponse} on successful completion of {@link + * Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listByResourceGroupSinglePageAsync( + 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 (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listByResourceGroup( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + resourceGroupName, + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink, context)); + } + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Get all the IoT hubs in 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 all the IoT hubs in a subscription along with {@link PagedResponse} on successful completion of {@link + * Mono}. + */ + @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.")); + } + 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(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + 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 all the IoT hubs in a subscription. + * + * @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 all the IoT hubs in a subscription along with {@link PagedResponse} on successful completion of {@link + * Mono}. + */ + @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.")); + } + 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(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Get all the IoT hubs in 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 all the IoT hubs in a subscription as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Get all the IoT hubs in a subscription. + * + * @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 all the IoT hubs in a subscription as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Get all the IoT hubs in 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 all the IoT hubs in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Get all the IoT hubs in a subscription. + * + * @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 all the IoT hubs in a subscription as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available along with {@link + * Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> checkDeviceServiceNameAvailabilityWithResponseAsync( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters) { + 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 (deviceServiceCheckNameAvailabilityParameters == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter deviceServiceCheckNameAvailabilityParameters is required and cannot be null.")); + } else { + deviceServiceCheckNameAvailabilityParameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .checkDeviceServiceNameAvailability( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + deviceServiceCheckNameAvailabilityParameters, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available along with {@link + * Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> checkDeviceServiceNameAvailabilityWithResponseAsync( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters, 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 (deviceServiceCheckNameAvailabilityParameters == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter deviceServiceCheckNameAvailabilityParameters is required and cannot be null.")); + } else { + deviceServiceCheckNameAvailabilityParameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .checkDeviceServiceNameAvailability( + this.client.getEndpoint(), + this.client.getApiVersion(), + this.client.getSubscriptionId(), + deviceServiceCheckNameAvailabilityParameters, + accept, + context); + } + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available on successful + * completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono checkDeviceServiceNameAvailabilityAsync( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters) { + return checkDeviceServiceNameAvailabilityWithResponseAsync(deviceServiceCheckNameAvailabilityParameters) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public DeviceServiceNameAvailabilityInfoInner checkDeviceServiceNameAvailability( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters) { + return checkDeviceServiceNameAvailabilityAsync(deviceServiceCheckNameAvailabilityParameters).block(); + } + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available along with {@link + * Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response checkDeviceServiceNameAvailabilityWithResponse( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters, Context context) { + return checkDeviceServiceNameAvailabilityWithResponseAsync( + deviceServiceCheckNameAvailabilityParameters, context) + .block(); + } + + /** + * 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 the JSON-serialized array of DeviceService objects with a next link along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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 the JSON-serialized array of DeviceService objects with a next link along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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)); + } + + /** + * 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 the JSON-serialized array of DeviceService objects with a next link along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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 the JSON-serialized array of DeviceService objects with a next link along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @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/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/ServicesImpl.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/ServicesImpl.java new file mode 100644 index 0000000000000..3500cf24fc7d6 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/ServicesImpl.java @@ -0,0 +1,219 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.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.windowsiot.fluent.ServicesClient; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceInner; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceNameAvailabilityInfoInner; +import com.azure.resourcemanager.windowsiot.models.DeviceService; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceCheckNameAvailabilityParameters; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceNameAvailabilityInfo; +import com.azure.resourcemanager.windowsiot.models.Services; + +public final class ServicesImpl implements Services { + private static final ClientLogger LOGGER = new ClientLogger(ServicesImpl.class); + + private final ServicesClient innerClient; + + private final com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager; + + public ServicesImpl( + ServicesClient innerClient, com.azure.resourcemanager.windowsiot.WindowsiotManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public DeviceService getByResourceGroup(String resourceGroupName, String deviceName) { + DeviceServiceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, deviceName); + if (inner != null) { + return new DeviceServiceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String deviceName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, deviceName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new DeviceServiceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public DeviceService deleteByResourceGroup(String resourceGroupName, String deviceName) { + DeviceServiceInner inner = this.serviceClient().delete(resourceGroupName, deviceName); + if (inner != null) { + return new DeviceServiceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteWithResponse(String resourceGroupName, String deviceName, Context context) { + Response inner = + this.serviceClient().deleteWithResponse(resourceGroupName, deviceName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new DeviceServiceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new DeviceServiceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new DeviceServiceImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new DeviceServiceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new DeviceServiceImpl(inner1, this.manager())); + } + + public DeviceServiceNameAvailabilityInfo checkDeviceServiceNameAvailability( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters) { + DeviceServiceNameAvailabilityInfoInner inner = + this.serviceClient().checkDeviceServiceNameAvailability(deviceServiceCheckNameAvailabilityParameters); + if (inner != null) { + return new DeviceServiceNameAvailabilityInfoImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response checkDeviceServiceNameAvailabilityWithResponse( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters, Context context) { + Response inner = + this + .serviceClient() + .checkDeviceServiceNameAvailabilityWithResponse(deviceServiceCheckNameAvailabilityParameters, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new DeviceServiceNameAvailabilityInfoImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public DeviceService 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 deviceName = Utils.getValueFromIdByName(id, "deviceServices"); + if (deviceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'deviceServices'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, deviceName, 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 deviceName = Utils.getValueFromIdByName(id, "deviceServices"); + if (deviceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'deviceServices'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, deviceName, context); + } + + public DeviceService 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 deviceName = Utils.getValueFromIdByName(id, "deviceServices"); + if (deviceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'deviceServices'.", id))); + } + return this.deleteWithResponse(resourceGroupName, deviceName, 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 deviceName = Utils.getValueFromIdByName(id, "deviceServices"); + if (deviceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'deviceServices'.", id))); + } + return this.deleteWithResponse(resourceGroupName, deviceName, context); + } + + private ServicesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.windowsiot.WindowsiotManager manager() { + return this.serviceManager; + } + + public DeviceServiceImpl define(String name) { + return new DeviceServiceImpl(name, this.manager()); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/Utils.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/Utils.java new file mode 100644 index 0000000000000..605c30b31a94c --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/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.windowsiot.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/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/package-info.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/implementation/package-info.java new file mode 100644 index 0000000000000..8a7286b3ac29a --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/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 DeviceServices. Use this API to manage the Windows IoT device services in + * your Azure subscription. + */ +package com.azure.resourcemanager.windowsiot.implementation; diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceService.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceService.java new file mode 100644 index 0000000000000..ea01baa810a1b --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceService.java @@ -0,0 +1,378 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.models; + +import com.azure.core.management.Region; +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceInner; +import java.time.OffsetDateTime; +import java.util.Map; + +/** An immutable client-side representation of DeviceService. */ +public interface DeviceService { + /** + * 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 etag property: The Etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal ETag convention. + * + * @return the etag value. + */ + String etag(); + + /** + * Gets the notes property: Windows IoT Device Service notes. + * + * @return the notes value. + */ + String notes(); + + /** + * Gets the startDate property: Windows IoT Device Service start date,. + * + * @return the startDate value. + */ + OffsetDateTime startDate(); + + /** + * Gets the quantity property: Windows IoT Device Service device allocation,. + * + * @return the quantity value. + */ + Long quantity(); + + /** + * Gets the billingDomainName property: Windows IoT Device Service ODM AAD domain. + * + * @return the billingDomainName value. + */ + String billingDomainName(); + + /** + * Gets the adminDomainName property: Windows IoT Device Service OEM AAD domain. + * + * @return the adminDomainName value. + */ + String adminDomainName(); + + /** + * 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.windowsiot.fluent.models.DeviceServiceInner object. + * + * @return the inner object. + */ + DeviceServiceInner innerModel(); + + /** The entirety of the DeviceService definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + /** The DeviceService definition stages. */ + interface DefinitionStages { + /** The first stage of the DeviceService definition. */ + interface Blank extends WithLocation { + } + /** The stage of the DeviceService 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 DeviceService definition allowing to specify parent resource. */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + /** + * The stage of the DeviceService 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, + DefinitionStages.WithEtag, + DefinitionStages.WithNotes, + DefinitionStages.WithQuantity, + DefinitionStages.WithBillingDomainName, + DefinitionStages.WithAdminDomainName, + DefinitionStages.WithIfMatch { + /** + * Executes the create request. + * + * @return the created resource. + */ + DeviceService create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + DeviceService create(Context context); + } + /** The stage of the DeviceService 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); + } + /** The stage of the DeviceService definition allowing to specify etag. */ + interface WithEtag { + /** + * Specifies the etag property: The Etag field is *not* required. If it is provided in the response body, it + * must also be provided as a header per the normal ETag convention.. + * + * @param etag The Etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal ETag convention. + * @return the next definition stage. + */ + WithCreate withEtag(String etag); + } + /** The stage of the DeviceService definition allowing to specify notes. */ + interface WithNotes { + /** + * Specifies the notes property: Windows IoT Device Service notes.. + * + * @param notes Windows IoT Device Service notes. + * @return the next definition stage. + */ + WithCreate withNotes(String notes); + } + /** The stage of the DeviceService definition allowing to specify quantity. */ + interface WithQuantity { + /** + * Specifies the quantity property: Windows IoT Device Service device allocation,. + * + * @param quantity Windows IoT Device Service device allocation,. + * @return the next definition stage. + */ + WithCreate withQuantity(Long quantity); + } + /** The stage of the DeviceService definition allowing to specify billingDomainName. */ + interface WithBillingDomainName { + /** + * Specifies the billingDomainName property: Windows IoT Device Service ODM AAD domain. + * + * @param billingDomainName Windows IoT Device Service ODM AAD domain. + * @return the next definition stage. + */ + WithCreate withBillingDomainName(String billingDomainName); + } + /** The stage of the DeviceService definition allowing to specify adminDomainName. */ + interface WithAdminDomainName { + /** + * Specifies the adminDomainName property: Windows IoT Device Service OEM AAD domain. + * + * @param adminDomainName Windows IoT Device Service OEM AAD domain. + * @return the next definition stage. + */ + WithCreate withAdminDomainName(String adminDomainName); + } + /** The stage of the DeviceService definition allowing to specify ifMatch. */ + interface WithIfMatch { + /** + * Specifies the ifMatch property: ETag of the Windows IoT Device Service. Do not specify for creating a new + * Windows IoT Device Service. Required to update an existing Windows IoT Device Service.. + * + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a new Windows IoT + * Device Service. Required to update an existing Windows IoT Device Service. + * @return the next definition stage. + */ + WithCreate withIfMatch(String ifMatch); + } + } + /** + * Begins update for the DeviceService resource. + * + * @return the stage of resource update. + */ + DeviceService.Update update(); + + /** The template for DeviceService update. */ + interface Update + extends UpdateStages.WithTags, + UpdateStages.WithEtag, + UpdateStages.WithNotes, + UpdateStages.WithQuantity, + UpdateStages.WithBillingDomainName, + UpdateStages.WithAdminDomainName, + UpdateStages.WithIfMatch { + /** + * Executes the update request. + * + * @return the updated resource. + */ + DeviceService apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + DeviceService apply(Context context); + } + /** The DeviceService update stages. */ + interface UpdateStages { + /** The stage of the DeviceService 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); + } + /** The stage of the DeviceService update allowing to specify etag. */ + interface WithEtag { + /** + * Specifies the etag property: The Etag field is *not* required. If it is provided in the response body, it + * must also be provided as a header per the normal ETag convention.. + * + * @param etag The Etag field is *not* required. If it is provided in the response body, it must also be + * provided as a header per the normal ETag convention. + * @return the next definition stage. + */ + Update withEtag(String etag); + } + /** The stage of the DeviceService update allowing to specify notes. */ + interface WithNotes { + /** + * Specifies the notes property: Windows IoT Device Service notes.. + * + * @param notes Windows IoT Device Service notes. + * @return the next definition stage. + */ + Update withNotes(String notes); + } + /** The stage of the DeviceService update allowing to specify quantity. */ + interface WithQuantity { + /** + * Specifies the quantity property: Windows IoT Device Service device allocation,. + * + * @param quantity Windows IoT Device Service device allocation,. + * @return the next definition stage. + */ + Update withQuantity(Long quantity); + } + /** The stage of the DeviceService update allowing to specify billingDomainName. */ + interface WithBillingDomainName { + /** + * Specifies the billingDomainName property: Windows IoT Device Service ODM AAD domain. + * + * @param billingDomainName Windows IoT Device Service ODM AAD domain. + * @return the next definition stage. + */ + Update withBillingDomainName(String billingDomainName); + } + /** The stage of the DeviceService update allowing to specify adminDomainName. */ + interface WithAdminDomainName { + /** + * Specifies the adminDomainName property: Windows IoT Device Service OEM AAD domain. + * + * @param adminDomainName Windows IoT Device Service OEM AAD domain. + * @return the next definition stage. + */ + Update withAdminDomainName(String adminDomainName); + } + /** The stage of the DeviceService update allowing to specify ifMatch. */ + interface WithIfMatch { + /** + * Specifies the ifMatch property: ETag of the Windows IoT Device Service. Do not specify for creating a + * brand new Windows IoT Device Service. Required to update an existing Windows IoT Device Service.. + * + * @param ifMatch ETag of the Windows IoT Device Service. Do not specify for creating a brand new Windows + * IoT Device Service. Required to update an existing Windows IoT Device Service. + * @return the next definition stage. + */ + Update withIfMatch(String ifMatch); + } + } + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + DeviceService refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + DeviceService refresh(Context context); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceCheckNameAvailabilityParameters.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceCheckNameAvailabilityParameters.java new file mode 100644 index 0000000000000..930956a36266b --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceCheckNameAvailabilityParameters.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Input values. */ +@Fluent +public final class DeviceServiceCheckNameAvailabilityParameters { + /* + * The name of the Windows IoT Device Service to check. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * Get the name property: The name of the Windows IoT Device Service to check. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: The name of the Windows IoT Device Service to check. + * + * @param name the name value to set. + * @return the DeviceServiceCheckNameAvailabilityParameters object itself. + */ + public DeviceServiceCheckNameAvailabilityParameters withName(String name) { + this.name = name; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property name in model DeviceServiceCheckNameAvailabilityParameters")); + } + } + + private static final ClientLogger LOGGER = new ClientLogger(DeviceServiceCheckNameAvailabilityParameters.class); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceDescriptionListResult.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceDescriptionListResult.java new file mode 100644 index 0000000000000..7008e547095fb --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceDescriptionListResult.java @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The JSON-serialized array of DeviceService objects with a next link. */ +@Fluent +public final class DeviceServiceDescriptionListResult { + /* + * The array of DeviceService objects. + */ + @JsonProperty(value = "value") + private List value; + + /* + * The next link. + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** + * Get the value property: The array of DeviceService objects. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: The array of DeviceService objects. + * + * @param value the value value to set. + * @return the DeviceServiceDescriptionListResult object itself. + */ + public DeviceServiceDescriptionListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: The next link. + * + * @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/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceNameAvailabilityInfo.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceNameAvailabilityInfo.java new file mode 100644 index 0000000000000..f64e697a3e3c6 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/DeviceServiceNameAvailabilityInfo.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.windowsiot.models; + +import com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceNameAvailabilityInfoInner; + +/** An immutable client-side representation of DeviceServiceNameAvailabilityInfo. */ +public interface DeviceServiceNameAvailabilityInfo { + /** + * Gets the nameAvailable property: The value which indicates whether the provided name is available. + * + * @return the nameAvailable value. + */ + Boolean nameAvailable(); + + /** + * Gets the reason property: The reason for unavailability. + * + * @return the reason value. + */ + ServiceNameUnavailabilityReason reason(); + + /** + * Gets the message property: The detailed reason message. + * + * @return the message value. + */ + String message(); + + /** + * Gets the inner com.azure.resourcemanager.windowsiot.fluent.models.DeviceServiceNameAvailabilityInfoInner object. + * + * @return the inner object. + */ + DeviceServiceNameAvailabilityInfoInner innerModel(); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationDisplayInfo.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationDisplayInfo.java new file mode 100644 index 0000000000000..76244ba7c67b7 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationDisplayInfo.java @@ -0,0 +1,124 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The operation supported by Azure Data Catalog Service. */ +@Fluent +public final class OperationDisplayInfo { + /* + * The description of the operation. + */ + @JsonProperty(value = "description") + private String description; + + /* + * The action that users can perform, based on their permission level. + */ + @JsonProperty(value = "operation") + private String operation; + + /* + * Service provider: Azure Data Catalog Service. + */ + @JsonProperty(value = "provider") + private String provider; + + /* + * Resource on which the operation is performed. + */ + @JsonProperty(value = "resource") + private String resource; + + /** + * Get the description property: The description of the operation. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: The description of the operation. + * + * @param description the description value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the operation property: The action that users can perform, based on their permission level. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Set the operation property: The action that users can perform, based on their permission level. + * + * @param operation the operation value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withOperation(String operation) { + this.operation = operation; + return this; + } + + /** + * Get the provider property: Service provider: Azure Data Catalog Service. + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider property: Service provider: Azure Data Catalog Service. + * + * @param provider the provider value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the resource property: Resource on which the operation is performed. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Set the resource property: Resource on which the operation is performed. + * + * @param resource the resource value to set. + * @return the OperationDisplayInfo object itself. + */ + public OperationDisplayInfo withResource(String resource) { + this.resource = resource; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationEntity.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationEntity.java new file mode 100644 index 0000000000000..ba0f3cb41bb9e --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationEntity.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.windowsiot.models; + +import com.azure.resourcemanager.windowsiot.fluent.models.OperationEntityInner; + +/** An immutable client-side representation of OperationEntity. */ +public interface OperationEntity { + /** + * Gets the name property: Operation name: {provider}/{resource}/{operation}. + * + * @return the name value. + */ + String name(); + + /** + * Gets the display property: The operation supported by Azure Data Catalog Service. + * + * @return the display value. + */ + OperationDisplayInfo display(); + + /** + * Gets the isDataAction property: Indicates whether the operation is a data action. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the origin property: Indicates the executor of the operation. + * + * @return the origin value. + */ + String origin(); + + /** + * Gets the inner com.azure.resourcemanager.windowsiot.fluent.models.OperationEntityInner object. + * + * @return the inner object. + */ + OperationEntityInner innerModel(); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationListResult.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationListResult.java new file mode 100644 index 0000000000000..24dfe62bc90cd --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/OperationListResult.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.models; + +import com.azure.core.annotation.Immutable; +import com.azure.resourcemanager.windowsiot.fluent.models.OperationEntityInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * Result of the request to list Windows IoT Device Service operations. It contains a list of operations and a URL link + * to get the next set of results. + */ +@Immutable +public final class OperationListResult { + /* + * List of Windows IoT Device Service operations supported by the + * Microsoft.WindowsIoT 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 Windows IoT Device Service operations supported by the Microsoft.WindowsIoT + * 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/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/Operations.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/Operations.java new file mode 100644 index 0000000000000..ff3a54be34f2c --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/Operations.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * Lists all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedIterable}. + */ + PagedIterable list(); + + /** + * Lists all of the available Windows IoT Services REST API operations. + * + * @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 result of the request to list Windows IoT Device Service operations as paginated response with {@link + * PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/ServiceNameUnavailabilityReason.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/ServiceNameUnavailabilityReason.java new file mode 100644 index 0000000000000..71721f6a2e462 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/ServiceNameUnavailabilityReason.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for ServiceNameUnavailabilityReason. */ +public enum ServiceNameUnavailabilityReason { + /** Enum value Invalid. */ + INVALID("Invalid"), + + /** Enum value AlreadyExists. */ + ALREADY_EXISTS("AlreadyExists"); + + /** The actual serialized value for a ServiceNameUnavailabilityReason instance. */ + private final String value; + + ServiceNameUnavailabilityReason(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ServiceNameUnavailabilityReason instance. + * + * @param value the serialized value to parse. + * @return the parsed ServiceNameUnavailabilityReason object, or null if unable to parse. + */ + @JsonCreator + public static ServiceNameUnavailabilityReason fromString(String value) { + ServiceNameUnavailabilityReason[] items = ServiceNameUnavailabilityReason.values(); + for (ServiceNameUnavailabilityReason item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/Services.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/Services.java new file mode 100644 index 0000000000000..d1d886de3b648 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/Services.java @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.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 Services. */ +public interface Services { + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service. + */ + DeviceService getByResourceGroup(String resourceGroupName, String deviceName); + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 non-security related metadata of a Windows IoT Device Service along with {@link Response}. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String deviceName, Context context); + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service. + */ + DeviceService deleteByResourceGroup(String resourceGroupName, String deviceName); + + /** + * Delete a Windows IoT Device Service. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @param deviceName The name of the Windows IoT Device Service. + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + Response deleteWithResponse(String resourceGroupName, String deviceName, Context context); + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Get all the IoT hubs in a resource group. + * + * @param resourceGroupName The name of the resource group that contains the Windows IoT Device Service. + * @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 all the IoT hubs in a resource group as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Get all the IoT hubs in 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 all the IoT hubs in a subscription as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * Get all the IoT hubs in a subscription. + * + * @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 all the IoT hubs in a subscription as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available. + */ + DeviceServiceNameAvailabilityInfo checkDeviceServiceNameAvailability( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters); + + /** + * Check if a Windows IoT Device Service name is available. + * + * @param deviceServiceCheckNameAvailabilityParameters Set the name parameter in the + * DeviceServiceCheckNameAvailabilityParameters structure to the name of the Windows IoT Device Service to + * check. + * @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 properties indicating whether a given Windows IoT Device Service name is available along with {@link + * Response}. + */ + Response checkDeviceServiceNameAvailabilityWithResponse( + DeviceServiceCheckNameAvailabilityParameters deviceServiceCheckNameAvailabilityParameters, Context context); + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @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 the non-security related metadata of a Windows IoT Device Service along with {@link Response}. + */ + DeviceService getById(String id); + + /** + * Get the non-security related metadata of a Windows IoT Device Service. + * + * @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 non-security related metadata of a Windows IoT Device Service along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a Windows IoT Device Service. + * + * @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 the description of the Windows IoT Device Service along with {@link Response}. + */ + DeviceService deleteById(String id); + + /** + * Delete a Windows IoT Device Service. + * + * @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 description of the Windows IoT Device Service along with {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new DeviceService resource. + * + * @param name resource name. + * @return the first stage of the new DeviceService definition. + */ + DeviceService.DefinitionStages.Blank define(String name); +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/package-info.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/models/package-info.java new file mode 100644 index 0000000000000..666f98cf6881a --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/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 DeviceServices. Use this API to manage the Windows IoT device services in your + * Azure subscription. + */ +package com.azure.resourcemanager.windowsiot.models; diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/package-info.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/package-info.java new file mode 100644 index 0000000000000..a4133f0ef79ba --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/com/azure/resourcemanager/windowsiot/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 DeviceServices. Use this API to manage the Windows IoT device services in your + * Azure subscription. + */ +package com.azure.resourcemanager.windowsiot; diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/module-info.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/main/java/module-info.java new file mode 100644 index 0000000000000..b470cf3a192a5 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/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.windowsiot { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.windowsiot; + exports com.azure.resourcemanager.windowsiot.fluent; + exports com.azure.resourcemanager.windowsiot.fluent.models; + exports com.azure.resourcemanager.windowsiot.models; + + opens com.azure.resourcemanager.windowsiot.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.windowsiot.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/OperationsListSamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/OperationsListSamples.java new file mode 100644 index 0000000000000..2785056dad794 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/OperationsListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.generated; + +import com.azure.core.util.Context; + +/** Samples for Operations List. */ +public final class OperationsListSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/OperationsList.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void operationsList(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.operations().list(Context.NONE); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesCheckDeviceServiceNameAvailabilitySamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesCheckDeviceServiceNameAvailabilitySamples.java new file mode 100644 index 0000000000000..04a81f119846d --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesCheckDeviceServiceNameAvailabilitySamples.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.generated; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsiot.models.DeviceServiceCheckNameAvailabilityParameters; + +/** Samples for Services CheckDeviceServiceNameAvailability. */ +public final class ServicesCheckDeviceServiceNameAvailabilitySamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_CheckNameAvailability.json + */ + /** + * Sample code: Service_CheckNameAvailability. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceCheckNameAvailability(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager + .services() + .checkDeviceServiceNameAvailabilityWithResponse( + new DeviceServiceCheckNameAvailabilityParameters().withName("service3363"), Context.NONE); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesCreateOrUpdateSamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..20e2a0c60ba97 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesCreateOrUpdateSamples.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.generated; + +/** Samples for Services CreateOrUpdate. */ +public final class ServicesCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Create.json + */ + /** + * Sample code: Service_Create. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceCreate(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager + .services() + .define("service4445") + .withRegion("East US") + .withExistingResourceGroup("res9101") + .withNotes("blah") + .withQuantity(1000000L) + .withBillingDomainName("a.b.c") + .withAdminDomainName("d.e.f") + .create(); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesDeleteSamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesDeleteSamples.java new file mode 100644 index 0000000000000..65c2e37e0210f --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesDeleteSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.generated; + +import com.azure.core.util.Context; + +/** Samples for Services Delete. */ +public final class ServicesDeleteSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Delete.json + */ + /** + * Sample code: Service_Delete. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceDelete(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().deleteWithResponse("res4228", "service2434", Context.NONE); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesGetByResourceGroupSamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..18ebcd8e292e4 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesGetByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.generated; + +import com.azure.core.util.Context; + +/** Samples for Services GetByResourceGroup. */ +public final class ServicesGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_GetProperties.json + */ + /** + * Sample code: Services_GetProperties. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void servicesGetProperties(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().getByResourceGroupWithResponse("res9407", "service8596", Context.NONE); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesListByResourceGroupSamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesListByResourceGroupSamples.java new file mode 100644 index 0000000000000..a36c0f63b6cbb --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesListByResourceGroupSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.generated; + +import com.azure.core.util.Context; + +/** Samples for Services ListByResourceGroup. */ +public final class ServicesListByResourceGroupSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_ListByResourceGroup.json + */ + /** + * Sample code: Service_ListByResourceGroup. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceListByResourceGroup(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().listByResourceGroup("res6117", Context.NONE); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesListSamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesListSamples.java new file mode 100644 index 0000000000000..a0dac89073e78 --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.windowsiot.generated; + +import com.azure.core.util.Context; + +/** Samples for Services List. */ +public final class ServicesListSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_List.json + */ + /** + * Sample code: Service_List. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceList(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + manager.services().list(Context.NONE); + } +} diff --git a/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesUpdateSamples.java b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesUpdateSamples.java new file mode 100644 index 0000000000000..6da40346af25e --- /dev/null +++ b/sdk/windowsiot/azure-resourcemanager-windowsiot/src/samples/java/com/azure/resourcemanager/windowsiot/generated/ServicesUpdateSamples.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.windowsiot.generated; + +import com.azure.core.util.Context; +import com.azure.resourcemanager.windowsiot.models.DeviceService; + +/** Samples for Services Update. */ +public final class ServicesUpdateSamples { + /* + * x-ms-original-file: specification/windowsiot/resource-manager/Microsoft.WindowsIoT/stable/2019-06-01/examples/Service_Update.json + */ + /** + * Sample code: Service_Update. + * + * @param manager Entry point to WindowsiotManager. + */ + public static void serviceUpdate(com.azure.resourcemanager.windowsiot.WindowsiotManager manager) { + DeviceService resource = + manager.services().getByResourceGroupWithResponse("res9407", "service8596", Context.NONE).getValue(); + resource + .update() + .withNotes("blah") + .withQuantity(1000000L) + .withBillingDomainName("a.b.c") + .withAdminDomainName("d.e.f") + .apply(); + } +} diff --git a/sdk/windowsiot/ci.yml b/sdk/windowsiot/ci.yml new file mode 100644 index 0000000000000..953286d7022c2 --- /dev/null +++ b/sdk/windowsiot/ci.yml @@ -0,0 +1,39 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/windowsiot/ci.yml + - sdk/windowsiot/azure-resourcemanager-windowsiot/ + exclude: + - sdk/windowsiot/pom.xml + - sdk/windowsiot/azure-resourcemanager-windowsiot/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/windowsiot/ci.yml + - sdk/windowsiot/azure-resourcemanager-windowsiot/ + exclude: + - sdk/windowsiot/pom.xml + - sdk/windowsiot/azure-resourcemanager-windowsiot/pom.xml + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: windowsiot + Artifacts: + - name: azure-resourcemanager-windowsiot + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerwindowsiot diff --git a/sdk/windowsiot/pom.xml b/sdk/windowsiot/pom.xml new file mode 100644 index 0000000000000..0e971eece65e6 --- /dev/null +++ b/sdk/windowsiot/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-windowsiot-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-windowsiot + + + +