diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index d1fb5ee94f47..982710f2f147 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -421,6 +421,7 @@ com.azure.resourcemanager:azure-resourcemanager-managednetworkfabric;1.0.0;1.1.0 com.azure.resourcemanager:azure-resourcemanager-iotfirmwaredefense;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-quantum;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-sphere;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-scom;1.0.0-beta.1;1.0.0-beta.1 com.azure.tools:azure-sdk-archetype;1.0.0;1.2.0-beta.1 com.azure.tools:azure-sdk-build-tool;1.0.0-beta.1;1.0.0 diff --git a/pom.xml b/pom.xml index dcd2f35b48b4..03e77bfc2573 100644 --- a/pom.xml +++ b/pom.xml @@ -161,6 +161,7 @@ sdk/resourcemanager sdk/resourcemover sdk/schemaregistry + sdk/scom sdk/scvmm sdk/search sdk/security diff --git a/sdk/scom/azure-resourcemanager-scom/CHANGELOG.md b/sdk/scom/azure-resourcemanager-scom/CHANGELOG.md new file mode 100644 index 000000000000..aa78a228e49e --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2023-07-24) + +- Azure Resource Manager scom client library for Java. This package contains Microsoft Azure SDK for scom Management SDK. SCOM monitoring instance management APIs. Package tag package-2022-09-13-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). diff --git a/sdk/scom/azure-resourcemanager-scom/README.md b/sdk/scom/azure-resourcemanager-scom/README.md new file mode 100644 index 000000000000..88e8644acafd --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/README.md @@ -0,0 +1,107 @@ +# Azure Resource Manager scom client library for Java + +Azure Resource Manager scom client library for Java. + +This package contains Microsoft Azure SDK for scom Management SDK. SCOM monitoring instance management APIs. Package tag package-2022-09-13-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## We'd love to hear your feedback + +We're always working on improving our products and the way we communicate with our users. So we'd love to learn what's working and how we can do better. + +If you haven't already, please take a few minutes to [complete this short survey][survey] we have put together. + +Thank you in advance for your collaboration. We really appreciate your time! + +## Documentation + +Various documentation is available to help you get started + +- [API reference documentation][docs] + +## Getting started + +### Prerequisites + +- [Java Development Kit (JDK)][jdk] with version 8 or above +- [Azure Subscription][azure_subscription] + +### Adding the package to your product + +[//]: # ({x-version-update-start;com.azure.resourcemanager:azure-resourcemanager-scom;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-scom + 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] and [Azure Core Netty HTTP][azure_core_http_netty] packages provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configuration of the 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 `AZURE_SUBSCRIPTION_ID` environment variable. + +With above configuration, `azure` client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +ScomManager manager = ScomManager + .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/scom/azure-resourcemanager-scom/SAMPLE.md) + + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide][cg]. + +This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact with any additional questions or comments. + + +[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 +[cg]: https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%2Fscom%2Fazure-resourcemanager-scom%2FREADME.png) diff --git a/sdk/scom/azure-resourcemanager-scom/SAMPLE.md b/sdk/scom/azure-resourcemanager-scom/SAMPLE.md new file mode 100644 index 000000000000..6aa681cdf0cc --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/SAMPLE.md @@ -0,0 +1,282 @@ +# Code snippets and samples + + +## Instances + +- [CreateOrUpdate](#instances_createorupdate) +- [Delete](#instances_delete) +- [GetByResourceGroup](#instances_getbyresourcegroup) +- [List](#instances_list) +- [ListByResourceGroup](#instances_listbyresourcegroup) +- [PatchServers](#instances_patchservers) +- [Scale](#instances_scale) +- [Update](#instances_update) + +## Operations + +- [ListByResourceGroup](#operations_listbyresourcegroup) +### Instances_CreateOrUpdate + +```java +import com.azure.resourcemanager.scom.models.AzureHybridBenefitProperties; +import com.azure.resourcemanager.scom.models.DatabaseInstanceProperties; +import com.azure.resourcemanager.scom.models.DomainControllerProperties; +import com.azure.resourcemanager.scom.models.DomainUserCredentials; +import com.azure.resourcemanager.scom.models.GmsaDetails; +import com.azure.resourcemanager.scom.models.HybridLicenseType; +import com.azure.resourcemanager.scom.models.ManagedIdentity; +import com.azure.resourcemanager.scom.models.ManagedIdentityType; +import com.azure.resourcemanager.scom.models.MonitoringInstanceProperties; +import com.azure.resourcemanager.scom.models.UserIdentity; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Instances CreateOrUpdate. */ +public final class InstancesCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Create.json + */ + /** + * Sample code: Instances_CreateOrUpdate. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesCreateOrUpdate(com.azure.resourcemanager.scom.ScomManager manager) { + manager + .instances() + .define("myInstace") + .withRegion("eastus2") + .withExistingResourceGroup("myResGroup") + .withTags(mapOf()) + .withProperties( + new MonitoringInstanceProperties() + .withVNetSubnetId( + "/subscriptions/{subscription-id}/resourceGroups/mySCOMMIGroup/providers/Microsoft.Network/virtualNetworks/vNet2/subnets/default") + .withDatabaseInstance( + new DatabaseInstanceProperties() + .withDatabaseInstanceId( + "/subscriptions/{subscription-id}/resourceGroups/mySCOMMIGroup/providers/Microsoft.sql/managedInstances/inst1")) + .withDomainController( + new DomainControllerProperties().withDomainName("domain.com").withDnsServer("10.10.10.10")) + .withDomainUserCredentials( + new DomainUserCredentials() + .withKeyVaultUrl("fakeTokenPlaceholder") + .withUsernameSecret("fakeTokenPlaceholder") + .withPasswordSecret("fakeTokenPlaceholder")) + .withGmsaDetails( + new GmsaDetails() + .withLoadBalancerIp("10.10.10.10") + .withGmsaAccount("vmsslb2$") + .withManagementServerGroupName("servergroup") + .withDnsName("dnsname.com")) + .withAzureHybridBenefit( + new AzureHybridBenefitProperties() + .withScomLicenseType(HybridLicenseType.NONE) + .withWindowsServerLicenseType(HybridLicenseType.NONE) + .withSqlServerLicenseType(HybridLicenseType.NONE))) + .withIdentity( + new ManagedIdentity() + .withType(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED) + .withUserAssignedIdentities( + mapOf( + "/subscriptions/subid/resourceGroups/mySCOMMIGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", + new UserIdentity()))) + .create(); + } + + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Instances_Delete + +```java +/** Samples for Instances Delete. */ +public final class InstancesDeleteSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Delete.json + */ + /** + * Sample code: Instances_Delete. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesDelete(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().delete("mySCOMMIGroup", "myInstace", com.azure.core.util.Context.NONE); + } +} +``` + +### Instances_GetByResourceGroup + +```java +/** Samples for Instances GetByResourceGroup. */ +public final class InstancesGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Get.json + */ + /** + * Sample code: Instances_Get. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesGet(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().getByResourceGroupWithResponse("myResGroup", "myInstace", com.azure.core.util.Context.NONE); + } +} +``` + +### Instances_List + +```java +/** Samples for Instances List. */ +public final class InstancesListSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instances_ListBySubscription.json + */ + /** + * Sample code: Instances_ListBySubscription. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesListBySubscription(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().list(com.azure.core.util.Context.NONE); + } +} +``` + +### Instances_ListByResourceGroup + +```java +/** Samples for Instances ListByResourceGroup. */ +public final class InstancesListByResourceGroupSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instances_ListByResourceGroup.json + */ + /** + * Sample code: Instances_ListByResourceGroup. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesListByResourceGroup(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().listByResourceGroup("mySCOMMIGroup", com.azure.core.util.Context.NONE); + } +} +``` + +### Instances_PatchServers + +```java +/** Samples for Instances PatchServers. */ +public final class InstancesPatchServersSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instances_PatchServers.json + */ + /** + * Sample code: Instances_PatchServers. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesPatchServers(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().patchServers("myResGroup", "myInstace", com.azure.core.util.Context.NONE); + } +} +``` + +### Instances_Scale + +```java +import com.azure.resourcemanager.scom.models.ScalingProperties; + +/** Samples for Instances Scale. */ +public final class InstancesScaleSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Scale.json + */ + /** + * Sample code: Instances_Scale. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesScale(com.azure.resourcemanager.scom.ScomManager manager) { + manager + .instances() + .scale( + "myResGroup", + "myInstace", + new ScalingProperties().withServerCount(3L), + com.azure.core.util.Context.NONE); + } +} +``` + +### Instances_Update + +```java +import com.azure.resourcemanager.scom.models.MonitoringInstance; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Instances Update. */ +public final class InstancesUpdateSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Update.json + */ + /** + * Sample code: Instances_Patch. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesPatch(com.azure.resourcemanager.scom.ScomManager manager) { + MonitoringInstance resource = + manager + .instances() + .getByResourceGroupWithResponse("myResGroup", "myInstace", com.azure.core.util.Context.NONE) + .getValue(); + resource + .update() + .withTags(mapOf("additionalProp1", "string", "additionalProp2", "string", "additionalProp3", "string")) + .apply(); + } + + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} +``` + +### Operations_ListByResourceGroup + +```java +/** Samples for Operations ListByResourceGroup. */ +public final class OperationsListByResourceGroupSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to ScomManager. + */ + public static void operationsList(com.azure.resourcemanager.scom.ScomManager manager) { + manager.operations().listByResourceGroup("myGroup", com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/scom/azure-resourcemanager-scom/pom.xml b/sdk/scom/azure-resourcemanager-scom/pom.xml new file mode 100644 index 000000000000..676b0069fa73 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-scom + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for scom Management + This package contains Microsoft Azure SDK for scom Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. SCOM monitoring instance management APIs. Package tag package-2022-09-13-preview. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + 0 + 0 + + + + com.azure + azure-core + 1.41.0 + + + com.azure + azure-core-management + 1.11.3 + + + diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/ScomManager.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/ScomManager.java new file mode 100644 index 000000000000..b1c1ca3a0196 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/ScomManager.java @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom; + +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.AddHeadersFromContextPolicy; +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.RetryOptions; +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.scom.fluent.AzureApiForManagingScomMonitoringInstances; +import com.azure.resourcemanager.scom.implementation.AzureApiForManagingScomMonitoringInstancesBuilder; +import com.azure.resourcemanager.scom.implementation.InstancesImpl; +import com.azure.resourcemanager.scom.implementation.OperationsImpl; +import com.azure.resourcemanager.scom.models.Instances; +import com.azure.resourcemanager.scom.models.Operations; +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 ScomManager. SCOM monitoring instance management APIs. */ +public final class ScomManager { + private Operations operations; + + private Instances instances; + + private final AzureApiForManagingScomMonitoringInstances clientObject; + + private ScomManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new AzureApiForManagingScomMonitoringInstancesBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of scom service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the scom service API instance. + */ + public static ScomManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Creates an instance of scom service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the scom service API instance. + */ + public static ScomManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new ScomManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create ScomManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ScomManager.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 RetryOptions retryOptions; + 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 retry options for the HTTP pipeline retry policy. + * + *

This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}. + * + * @param retryOptions the retry options for the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryOptions(RetryOptions retryOptions) { + this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' 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 scom service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the scom service API instance. + */ + public ScomManager 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.scom") + .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) { + if (retryOptions != null) { + retryPolicy = new RetryPolicy(retryOptions); + } else { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new AddHeadersFromContextPolicy()); + 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 ScomManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** + * Gets the resource collection API of Operations. + * + * @return Resource collection API of Operations. + */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * Gets the resource collection API of Instances. It manages MonitoringInstance. + * + * @return Resource collection API of Instances. + */ + public Instances instances() { + if (this.instances == null) { + this.instances = new InstancesImpl(clientObject.getInstances(), this); + } + return instances; + } + + /** + * @return Wrapped service client AzureApiForManagingScomMonitoringInstances providing direct access to the + * underlying auto-generated API implementation, based on Azure REST API. + */ + public AzureApiForManagingScomMonitoringInstances serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/AzureApiForManagingScomMonitoringInstances.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/AzureApiForManagingScomMonitoringInstances.java new file mode 100644 index 000000000000..4dafc70507b1 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/AzureApiForManagingScomMonitoringInstances.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.scom.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for AzureApiForManagingScomMonitoringInstances class. */ +public interface AzureApiForManagingScomMonitoringInstances { + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); + + /** + * Gets the InstancesClient object to access its operations. + * + * @return the InstancesClient object. + */ + InstancesClient getInstances(); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/InstancesClient.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/InstancesClient.java new file mode 100644 index 000000000000..f3f5628566bc --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/InstancesClient.java @@ -0,0 +1,388 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.scom.fluent.models.MonitoringInstanceInner; +import com.azure.resourcemanager.scom.models.MonitoringInstancePatch; +import com.azure.resourcemanager.scom.models.ScalingProperties; + +/** An instance of this class provides access to all the operations defined in InstancesClient. */ +public interface InstancesClient { + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse( + String resourceGroupName, String instanceName, Context context); + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MonitoringInstanceInner getByResourceGroup(String resourceGroupName, String instanceName); + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, MonitoringInstanceInner> beginCreateOrUpdate( + String resourceGroupName, String instanceName, MonitoringInstanceInner monitoringInstance); + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, MonitoringInstanceInner> beginCreateOrUpdate( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode, + Context context); + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MonitoringInstanceInner createOrUpdate( + String resourceGroupName, String instanceName, MonitoringInstanceInner monitoringInstance); + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MonitoringInstanceInner createOrUpdate( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode, + Context context); + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, MonitoringInstanceInner> beginUpdate( + String resourceGroupName, String instanceName); + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, MonitoringInstanceInner> beginUpdate( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance, Context context); + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MonitoringInstanceInner update(String resourceGroupName, String instanceName); + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + MonitoringInstanceInner update( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance, Context context); + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String instanceName); + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginDelete(String resourceGroupName, String instanceName, Context context); + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String instanceName); + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String instanceName, Context context); + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginScale( + String resourceGroupName, String instanceName, ScalingProperties body); + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginScale( + String resourceGroupName, String instanceName, ScalingProperties body, Context context); + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void scale(String resourceGroupName, String instanceName, ScalingProperties body); + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void scale(String resourceGroupName, String instanceName, ScalingProperties body, Context context); + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginPatchServers(String resourceGroupName, String instanceName); + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + SyncPoller, Void> beginPatchServers( + String resourceGroupName, String instanceName, Context context); + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void patchServers(String resourceGroupName, String instanceName); + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void patchServers(String resourceGroupName, String instanceName, Context context); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/OperationsClient.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/OperationsClient.java new file mode 100644 index 000000000000..547dfc987d0a --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/OperationsClient.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.scom.fluent.models.OperationInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/MonitoringInstanceInner.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/MonitoringInstanceInner.java new file mode 100644 index 000000000000..b83929041121 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/MonitoringInstanceInner.java @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.resourcemanager.scom.models.ManagedIdentity; +import com.azure.resourcemanager.scom.models.MonitoringInstanceProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** A SCOM instance resource. */ +@Fluent +public final class MonitoringInstanceInner extends Resource { + /* + * The properties of a SCOM instance resource + */ + @JsonProperty(value = "properties") + private MonitoringInstanceProperties properties; + + /* + * The system data. + */ + @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY) + private SystemData systemData; + + /* + * The Azure Active Directory identity of the SCOM instance + */ + @JsonProperty(value = "identity") + private ManagedIdentity identity; + + /** Creates an instance of MonitoringInstanceInner class. */ + public MonitoringInstanceInner() { + } + + /** + * Get the properties property: The properties of a SCOM instance resource. + * + * @return the properties value. + */ + public MonitoringInstanceProperties properties() { + return this.properties; + } + + /** + * Set the properties property: The properties of a SCOM instance resource. + * + * @param properties the properties value to set. + * @return the MonitoringInstanceInner object itself. + */ + public MonitoringInstanceInner withProperties(MonitoringInstanceProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the systemData property: The system data. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the identity property: The Azure Active Directory identity of the SCOM instance. + * + * @return the identity value. + */ + public ManagedIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The Azure Active Directory identity of the SCOM instance. + * + * @param identity the identity value to set. + * @return the MonitoringInstanceInner object itself. + */ + public MonitoringInstanceInner withIdentity(ManagedIdentity identity) { + this.identity = identity; + return this; + } + + /** {@inheritDoc} */ + @Override + public MonitoringInstanceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** {@inheritDoc} */ + @Override + public MonitoringInstanceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (properties() != null) { + properties().validate(); + } + if (identity() != null) { + identity().validate(); + } + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/OperationInner.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/OperationInner.java new file mode 100644 index 000000000000..2d52a61225e4 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/OperationInner.java @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.resourcemanager.scom.models.OperationDisplay; +import com.azure.resourcemanager.scom.models.OperationOrigin; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** A REST API operation. */ +@Immutable +public final class OperationInner { + /* + * Name of the operation being performed on this object + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /* + * Contains the localized display information for this operation + */ + @JsonProperty(value = "display", access = JsonProperty.Access.WRITE_ONLY) + private OperationDisplay display; + + /* + * The intended executor of the operation. + */ + @JsonProperty(value = "origin", access = JsonProperty.Access.WRITE_ONLY) + private OperationOrigin origin; + + /** Creates an instance of OperationInner class. */ + public OperationInner() { + } + + /** + * Get the name property: Name of the operation being performed on this object. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the display property: Contains the localized display information for this operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Get the origin property: The intended executor of the operation. + * + * @return the origin value. + */ + public OperationOrigin origin() { + return this.origin; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/package-info.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/models/package-info.java new file mode 100644 index 000000000000..ee69a11bbb65 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/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 AzureApiForManagingScomMonitoringInstances. SCOM monitoring instance + * management APIs. + */ +package com.azure.resourcemanager.scom.fluent.models; diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/package-info.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/fluent/package-info.java new file mode 100644 index 000000000000..1997c9ef2736 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/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 AzureApiForManagingScomMonitoringInstances. SCOM monitoring instance + * management APIs. + */ +package com.azure.resourcemanager.scom.fluent; diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/AzureApiForManagingScomMonitoringInstancesBuilder.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/AzureApiForManagingScomMonitoringInstancesBuilder.java new file mode 100644 index 000000000000..b7f53829ed57 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/AzureApiForManagingScomMonitoringInstancesBuilder.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.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 AzureApiForManagingScomMonitoringInstancesImpl type. */ +@ServiceClientBuilder(serviceClients = {AzureApiForManagingScomMonitoringInstancesImpl.class}) +public final class AzureApiForManagingScomMonitoringInstancesBuilder { + /* + * The ID of the target subscription. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. + * + * @param subscriptionId the subscriptionId value. + * @return the AzureApiForManagingScomMonitoringInstancesBuilder. + */ + public AzureApiForManagingScomMonitoringInstancesBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the AzureApiForManagingScomMonitoringInstancesBuilder. + */ + public AzureApiForManagingScomMonitoringInstancesBuilder 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 AzureApiForManagingScomMonitoringInstancesBuilder. + */ + public AzureApiForManagingScomMonitoringInstancesBuilder environment(AzureEnvironment environment) { + this.environment = environment; + 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 AzureApiForManagingScomMonitoringInstancesBuilder. + */ + public AzureApiForManagingScomMonitoringInstancesBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + 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 AzureApiForManagingScomMonitoringInstancesBuilder. + */ + public AzureApiForManagingScomMonitoringInstancesBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + 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 AzureApiForManagingScomMonitoringInstancesBuilder. + */ + public AzureApiForManagingScomMonitoringInstancesBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of AzureApiForManagingScomMonitoringInstancesImpl with the provided parameters. + * + * @return an instance of AzureApiForManagingScomMonitoringInstancesImpl. + */ + public AzureApiForManagingScomMonitoringInstancesImpl buildClient() { + String localEndpoint = (endpoint != null) ? endpoint : "https://management.azure.com"; + AzureEnvironment localEnvironment = (environment != null) ? environment : AzureEnvironment.AZURE; + HttpPipeline localPipeline = + (pipeline != null) + ? pipeline + : new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(); + Duration localDefaultPollInterval = + (defaultPollInterval != null) ? defaultPollInterval : Duration.ofSeconds(30); + SerializerAdapter localSerializerAdapter = + (serializerAdapter != null) + ? serializerAdapter + : SerializerFactory.createDefaultManagementSerializerAdapter(); + AzureApiForManagingScomMonitoringInstancesImpl client = + new AzureApiForManagingScomMonitoringInstancesImpl( + localPipeline, + localSerializerAdapter, + localDefaultPollInterval, + localEnvironment, + subscriptionId, + localEndpoint); + return client; + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/AzureApiForManagingScomMonitoringInstancesImpl.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/AzureApiForManagingScomMonitoringInstancesImpl.java new file mode 100644 index 000000000000..e29d7c6be1a9 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/AzureApiForManagingScomMonitoringInstancesImpl.java @@ -0,0 +1,305 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.CoreUtils; +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.scom.fluent.AzureApiForManagingScomMonitoringInstances; +import com.azure.resourcemanager.scom.fluent.InstancesClient; +import com.azure.resourcemanager.scom.fluent.OperationsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the AzureApiForManagingScomMonitoringInstancesImpl type. */ +@ServiceClient(builder = AzureApiForManagingScomMonitoringInstancesBuilder.class) +public final class AzureApiForManagingScomMonitoringInstancesImpl + implements AzureApiForManagingScomMonitoringInstances { + /** The ID of the target subscription. */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** The default poll interval for long-running operation. */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** The 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 InstancesClient object to access its operations. */ + private final InstancesClient instances; + + /** + * Gets the InstancesClient object to access its operations. + * + * @return the InstancesClient object. + */ + public InstancesClient getInstances() { + return this.instances; + } + + /** + * Initializes an instance of AzureApiForManagingScomMonitoringInstances client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param subscriptionId The ID of the target subscription. + * @param endpoint server parameter. + */ + AzureApiForManagingScomMonitoringInstancesImpl( + 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 = "2022-09-13-preview"; + this.operations = new OperationsClientImpl(this); + this.instances = new InstancesClientImpl(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) { + return CoreUtils.mergeContexts(this.getContext(), 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(AzureApiForManagingScomMonitoringInstancesImpl.class); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/InstancesClientImpl.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/InstancesClientImpl.java new file mode 100644 index 000000000000..1c2aefd2333e --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/InstancesClientImpl.java @@ -0,0 +1,2196 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.management.polling.PollResult; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.polling.SyncPoller; +import com.azure.resourcemanager.scom.fluent.InstancesClient; +import com.azure.resourcemanager.scom.fluent.models.MonitoringInstanceInner; +import com.azure.resourcemanager.scom.models.MonitoringInstanceList; +import com.azure.resourcemanager.scom.models.MonitoringInstancePatch; +import com.azure.resourcemanager.scom.models.ScalingProperties; +import java.nio.ByteBuffer; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in InstancesClient. */ +public final class InstancesClientImpl implements InstancesClient { + /** The proxy service used to perform REST calls. */ + private final InstancesService service; + + /** The service client containing this operation class. */ + private final AzureApiForManagingScomMonitoringInstancesImpl client; + + /** + * Initializes an instance of InstancesClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + InstancesClientImpl(AzureApiForManagingScomMonitoringInstancesImpl client) { + this.service = + RestProxy.create(InstancesService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureApiForManagingScomMonitoringInstancesInstances to be used by the + * proxy service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureApiForManagingS") + public interface InstancesService { + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/managedInstances") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Scom/managedInstances") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/managedInstances/{instanceName}") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("instanceName") String instanceName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Put( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/managedInstances/{instanceName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> createOrUpdate( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("instanceName") String instanceName, + @QueryParam("api-version") String apiVersion, + @QueryParam("validationMode") Boolean validationMode, + @BodyParam("application/json") MonitoringInstanceInner monitoringInstance, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Patch( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/managedInstances/{instanceName}") + @ExpectedResponses({200, 201}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> update( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("instanceName") String instanceName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") MonitoringInstancePatch monitoringInstance, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Delete( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/managedInstances/{instanceName}") + @ExpectedResponses({200, 202, 204}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> delete( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("instanceName") String instanceName, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Post( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/managedInstances/{instanceName}/setServerCount") + @ExpectedResponses({200, 202}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> scale( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("instanceName") String instanceName, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ScalingProperties body, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Post( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/managedInstances/{instanceName}/patchServers") + @ExpectedResponses({200, 202}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono>> patchServers( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("instanceName") String instanceName, + @QueryParam("api-version") String apiVersion, + @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> listBySubscriptionNext( + @PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("$host") String endpoint, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances 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.getSubscriptionId(), + resourceGroupName, + 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 SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances 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.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances 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)); + } + + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances 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.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances 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.getSubscriptionId(), + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>( + () -> listSinglePageAsync(), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>( + () -> listSinglePageAsync(context), nextLink -> listBySubscriptionNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String instanceName) { + 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getByResourceGroupWithResponseAsync( + String resourceGroupName, String instanceName, 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .getByResourceGroup( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, String instanceName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, instanceName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse( + String resourceGroupName, String instanceName, Context context) { + return getByResourceGroupWithResponseAsync(resourceGroupName, instanceName, context).block(); + } + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MonitoringInstanceInner getByResourceGroup(String resourceGroupName, String instanceName) { + return getByResourceGroupWithResponse(resourceGroupName, instanceName, Context.NONE).getValue(); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode) { + 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + if (monitoringInstance == null) { + return Mono + .error(new IllegalArgumentException("Parameter monitoringInstance is required and cannot be null.")); + } else { + monitoringInstance.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + validationMode, + monitoringInstance, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> createOrUpdateWithResponseAsync( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode, + 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + if (monitoringInstance == null) { + return Mono + .error(new IllegalArgumentException("Parameter monitoringInstance is required and cannot be null.")); + } else { + monitoringInstance.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .createOrUpdate( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + validationMode, + monitoringInstance, + accept, + context); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @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 {@link PollerFlux} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MonitoringInstanceInner> beginCreateOrUpdateAsync( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode) { + Mono>> mono = + createOrUpdateWithResponseAsync(resourceGroupName, instanceName, monitoringInstance, validationMode); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MonitoringInstanceInner.class, + MonitoringInstanceInner.class, + this.client.getContext()); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @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 {@link PollerFlux} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MonitoringInstanceInner> beginCreateOrUpdateAsync( + String resourceGroupName, String instanceName, MonitoringInstanceInner monitoringInstance) { + final Boolean validationMode = null; + Mono>> mono = + createOrUpdateWithResponseAsync(resourceGroupName, instanceName, monitoringInstance, validationMode); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MonitoringInstanceInner.class, + MonitoringInstanceInner.class, + this.client.getContext()); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @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 {@link PollerFlux} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MonitoringInstanceInner> beginCreateOrUpdateAsync( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode, + Context context) { + context = this.client.mergeContext(context); + Mono>> mono = + createOrUpdateWithResponseAsync( + resourceGroupName, instanceName, monitoringInstance, validationMode, context); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MonitoringInstanceInner.class, + MonitoringInstanceInner.class, + context); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, MonitoringInstanceInner> beginCreateOrUpdate( + String resourceGroupName, String instanceName, MonitoringInstanceInner monitoringInstance) { + final Boolean validationMode = null; + return this + .beginCreateOrUpdateAsync(resourceGroupName, instanceName, monitoringInstance, validationMode) + .getSyncPoller(); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, MonitoringInstanceInner> beginCreateOrUpdate( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode, + Context context) { + return this + .beginCreateOrUpdateAsync(resourceGroupName, instanceName, monitoringInstance, validationMode, context) + .getSyncPoller(); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode) { + return beginCreateOrUpdateAsync(resourceGroupName, instanceName, monitoringInstance, validationMode) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, String instanceName, MonitoringInstanceInner monitoringInstance) { + final Boolean validationMode = null; + return beginCreateOrUpdateAsync(resourceGroupName, instanceName, monitoringInstance, validationMode) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode, + Context context) { + return beginCreateOrUpdateAsync(resourceGroupName, instanceName, monitoringInstance, validationMode, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MonitoringInstanceInner createOrUpdate( + String resourceGroupName, String instanceName, MonitoringInstanceInner monitoringInstance) { + final Boolean validationMode = null; + return createOrUpdateAsync(resourceGroupName, instanceName, monitoringInstance, validationMode).block(); + } + + /** + * Create or update SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM Monitoring Instance. + * @param validationMode Validation mode for the SCOM monitoring instance. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MonitoringInstanceInner createOrUpdate( + String resourceGroupName, + String instanceName, + MonitoringInstanceInner monitoringInstance, + Boolean validationMode, + Context context) { + return createOrUpdateAsync(resourceGroupName, instanceName, monitoringInstance, validationMode, context) + .block(); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance) { + 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + if (monitoringInstance != null) { + monitoringInstance.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + monitoringInstance, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> updateWithResponseAsync( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance, 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + if (monitoringInstance != null) { + monitoringInstance.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .update( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + monitoringInstance, + accept, + context); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @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 {@link PollerFlux} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MonitoringInstanceInner> beginUpdateAsync( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance) { + Mono>> mono = + updateWithResponseAsync(resourceGroupName, instanceName, monitoringInstance); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MonitoringInstanceInner.class, + MonitoringInstanceInner.class, + this.client.getContext()); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link PollerFlux} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MonitoringInstanceInner> beginUpdateAsync( + String resourceGroupName, String instanceName) { + final MonitoringInstancePatch monitoringInstance = null; + Mono>> mono = + updateWithResponseAsync(resourceGroupName, instanceName, monitoringInstance); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MonitoringInstanceInner.class, + MonitoringInstanceInner.class, + this.client.getContext()); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @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 {@link PollerFlux} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, MonitoringInstanceInner> beginUpdateAsync( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = + updateWithResponseAsync(resourceGroupName, instanceName, monitoringInstance, context); + return this + .client + .getLroResult( + mono, + this.client.getHttpPipeline(), + MonitoringInstanceInner.class, + MonitoringInstanceInner.class, + context); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, MonitoringInstanceInner> beginUpdate( + String resourceGroupName, String instanceName) { + final MonitoringInstancePatch monitoringInstance = null; + return this.beginUpdateAsync(resourceGroupName, instanceName, monitoringInstance).getSyncPoller(); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @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 {@link SyncPoller} for polling of a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, MonitoringInstanceInner> beginUpdate( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance, Context context) { + return this.beginUpdateAsync(resourceGroupName, instanceName, monitoringInstance, context).getSyncPoller(); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance) { + return beginUpdateAsync(resourceGroupName, instanceName, monitoringInstance) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String instanceName) { + final MonitoringInstancePatch monitoringInstance = null; + return beginUpdateAsync(resourceGroupName, instanceName, monitoringInstance) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance, Context context) { + return beginUpdateAsync(resourceGroupName, instanceName, monitoringInstance, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MonitoringInstanceInner update(String resourceGroupName, String instanceName) { + final MonitoringInstancePatch monitoringInstance = null; + return updateAsync(resourceGroupName, instanceName, monitoringInstance).block(); + } + + /** + * Patch SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param monitoringInstance SCOM monitoring instance properties update. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a SCOM instance resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public MonitoringInstanceInner update( + String resourceGroupName, String instanceName, MonitoringInstancePatch monitoringInstance, Context context) { + return updateAsync(resourceGroupName, instanceName, monitoringInstance, context).block(); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync(String resourceGroupName, String instanceName) { + 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> deleteWithResponseAsync( + String resourceGroupName, String instanceName, 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .delete( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync(String resourceGroupName, String instanceName) { + Mono>> mono = deleteWithResponseAsync(resourceGroupName, instanceName); + return this + .client + .getLroResult( + mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext()); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginDeleteAsync( + String resourceGroupName, String instanceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = deleteWithResponseAsync(resourceGroupName, instanceName, context); + return this + .client + .getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete(String resourceGroupName, String instanceName) { + return this.beginDeleteAsync(resourceGroupName, instanceName).getSyncPoller(); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginDelete( + String resourceGroupName, String instanceName, Context context) { + return this.beginDeleteAsync(resourceGroupName, instanceName, context).getSyncPoller(); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String instanceName) { + return beginDeleteAsync(resourceGroupName, instanceName).last().flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String instanceName, Context context) { + return beginDeleteAsync(resourceGroupName, instanceName, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String instanceName) { + deleteAsync(resourceGroupName, instanceName).block(); + } + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String instanceName, Context context) { + deleteAsync(resourceGroupName, instanceName, context).block(); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> scaleWithResponseAsync( + String resourceGroupName, String instanceName, ScalingProperties body) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .scale( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + body, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> scaleWithResponseAsync( + String resourceGroupName, String instanceName, ScalingProperties body, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + if (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + if (body == null) { + return Mono.error(new IllegalArgumentException("Parameter body is required and cannot be null.")); + } else { + body.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .scale( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + body, + accept, + context); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginScaleAsync( + String resourceGroupName, String instanceName, ScalingProperties body) { + Mono>> mono = scaleWithResponseAsync(resourceGroupName, instanceName, body); + return this + .client + .getLroResult( + mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext()); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginScaleAsync( + String resourceGroupName, String instanceName, ScalingProperties body, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = scaleWithResponseAsync(resourceGroupName, instanceName, body, context); + return this + .client + .getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginScale( + String resourceGroupName, String instanceName, ScalingProperties body) { + return this.beginScaleAsync(resourceGroupName, instanceName, body).getSyncPoller(); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginScale( + String resourceGroupName, String instanceName, ScalingProperties body, Context context) { + return this.beginScaleAsync(resourceGroupName, instanceName, body, context).getSyncPoller(); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono scaleAsync(String resourceGroupName, String instanceName, ScalingProperties body) { + return beginScaleAsync(resourceGroupName, instanceName, body) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono scaleAsync( + String resourceGroupName, String instanceName, ScalingProperties body, Context context) { + return beginScaleAsync(resourceGroupName, instanceName, body, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void scale(String resourceGroupName, String instanceName, ScalingProperties body) { + scaleAsync(resourceGroupName, instanceName, body).block(); + } + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void scale(String resourceGroupName, String instanceName, ScalingProperties body, Context context) { + scaleAsync(resourceGroupName, instanceName, body, context).block(); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> patchServersWithResponseAsync( + String resourceGroupName, String instanceName) { + 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .patchServers( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono>> patchServersWithResponseAsync( + String resourceGroupName, String instanceName, 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 (instanceName == null) { + return Mono.error(new IllegalArgumentException("Parameter instanceName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .patchServers( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + instanceName, + this.client.getApiVersion(), + accept, + context); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginPatchServersAsync(String resourceGroupName, String instanceName) { + Mono>> mono = patchServersWithResponseAsync(resourceGroupName, instanceName); + return this + .client + .getLroResult( + mono, this.client.getHttpPipeline(), Void.class, Void.class, this.client.getContext()); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link PollerFlux} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + private PollerFlux, Void> beginPatchServersAsync( + String resourceGroupName, String instanceName, Context context) { + context = this.client.mergeContext(context); + Mono>> mono = patchServersWithResponseAsync(resourceGroupName, instanceName, context); + return this + .client + .getLroResult(mono, this.client.getHttpPipeline(), Void.class, Void.class, context); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginPatchServers(String resourceGroupName, String instanceName) { + return this.beginPatchServersAsync(resourceGroupName, instanceName).getSyncPoller(); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 {@link SyncPoller} for polling of long-running operation. + */ + @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) + public SyncPoller, Void> beginPatchServers( + String resourceGroupName, String instanceName, Context context) { + return this.beginPatchServersAsync(resourceGroupName, instanceName, context).getSyncPoller(); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono patchServersAsync(String resourceGroupName, String instanceName) { + return beginPatchServersAsync(resourceGroupName, instanceName) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono patchServersAsync(String resourceGroupName, String instanceName, Context context) { + return beginPatchServersAsync(resourceGroupName, instanceName, context) + .last() + .flatMap(this.client::getLroFinalResultOrError); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void patchServers(String resourceGroupName, String instanceName) { + patchServersAsync(resourceGroupName, instanceName).block(); + } + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void patchServers(String resourceGroupName, String instanceName, Context context) { + patchServersAsync(resourceGroupName, instanceName, context).block(); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances 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 URL to get the next list of items + *

The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances 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 URL to get the next list of items + *

The nextLink parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync(String nextLink) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items + *

The nextLink parameter. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances along with {@link PagedResponse} on successful completion of + * {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listBySubscriptionNextSinglePageAsync( + String nextLink, Context context) { + if (nextLink == null) { + return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null.")); + } + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .listBySubscriptionNext(nextLink, this.client.getEndpoint(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/InstancesImpl.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/InstancesImpl.java new file mode 100644 index 000000000000..58c217d2ac21 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/InstancesImpl.java @@ -0,0 +1,194 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.scom.fluent.InstancesClient; +import com.azure.resourcemanager.scom.fluent.models.MonitoringInstanceInner; +import com.azure.resourcemanager.scom.models.Instances; +import com.azure.resourcemanager.scom.models.MonitoringInstance; +import com.azure.resourcemanager.scom.models.ScalingProperties; + +public final class InstancesImpl implements Instances { + private static final ClientLogger LOGGER = new ClientLogger(InstancesImpl.class); + + private final InstancesClient innerClient; + + private final com.azure.resourcemanager.scom.ScomManager serviceManager; + + public InstancesImpl(InstancesClient innerClient, com.azure.resourcemanager.scom.ScomManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new MonitoringInstanceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = + this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new MonitoringInstanceImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return Utils.mapPage(inner, inner1 -> new MonitoringInstanceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return Utils.mapPage(inner, inner1 -> new MonitoringInstanceImpl(inner1, this.manager())); + } + + public Response getByResourceGroupWithResponse( + String resourceGroupName, String instanceName, Context context) { + Response inner = + this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, instanceName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new MonitoringInstanceImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public MonitoringInstance getByResourceGroup(String resourceGroupName, String instanceName) { + MonitoringInstanceInner inner = this.serviceClient().getByResourceGroup(resourceGroupName, instanceName); + if (inner != null) { + return new MonitoringInstanceImpl(inner, this.manager()); + } else { + return null; + } + } + + public void deleteByResourceGroup(String resourceGroupName, String instanceName) { + this.serviceClient().delete(resourceGroupName, instanceName); + } + + public void delete(String resourceGroupName, String instanceName, Context context) { + this.serviceClient().delete(resourceGroupName, instanceName, context); + } + + public void scale(String resourceGroupName, String instanceName, ScalingProperties body) { + this.serviceClient().scale(resourceGroupName, instanceName, body); + } + + public void scale(String resourceGroupName, String instanceName, ScalingProperties body, Context context) { + this.serviceClient().scale(resourceGroupName, instanceName, body, context); + } + + public void patchServers(String resourceGroupName, String instanceName) { + this.serviceClient().patchServers(resourceGroupName, instanceName); + } + + public void patchServers(String resourceGroupName, String instanceName, Context context) { + this.serviceClient().patchServers(resourceGroupName, instanceName, context); + } + + public MonitoringInstance 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 instanceName = Utils.getValueFromIdByName(id, "managedInstances"); + if (instanceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'managedInstances'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, instanceName, 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 instanceName = Utils.getValueFromIdByName(id, "managedInstances"); + if (instanceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'managedInstances'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, instanceName, context); + } + + public void deleteById(String id) { + String resourceGroupName = Utils.getValueFromIdByName(id, "resourceGroups"); + if (resourceGroupName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format("The resource ID '%s' is not valid. Missing path segment 'resourceGroups'.", id))); + } + String instanceName = Utils.getValueFromIdByName(id, "managedInstances"); + if (instanceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'managedInstances'.", id))); + } + this.delete(resourceGroupName, instanceName, Context.NONE); + } + + public void 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 instanceName = Utils.getValueFromIdByName(id, "managedInstances"); + if (instanceName == null) { + throw LOGGER + .logExceptionAsError( + new IllegalArgumentException( + String + .format( + "The resource ID '%s' is not valid. Missing path segment 'managedInstances'.", id))); + } + this.delete(resourceGroupName, instanceName, context); + } + + private InstancesClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.scom.ScomManager manager() { + return this.serviceManager; + } + + public MonitoringInstanceImpl define(String name) { + return new MonitoringInstanceImpl(name, this.manager()); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/MonitoringInstanceImpl.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/MonitoringInstanceImpl.java new file mode 100644 index 000000000000..260a06fb539c --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/MonitoringInstanceImpl.java @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.scom.fluent.models.MonitoringInstanceInner; +import com.azure.resourcemanager.scom.models.ManagedIdentity; +import com.azure.resourcemanager.scom.models.MonitoringInstance; +import com.azure.resourcemanager.scom.models.MonitoringInstancePatch; +import com.azure.resourcemanager.scom.models.MonitoringInstanceProperties; +import com.azure.resourcemanager.scom.models.ScalingProperties; +import java.util.Collections; +import java.util.Map; + +public final class MonitoringInstanceImpl + implements MonitoringInstance, MonitoringInstance.Definition, MonitoringInstance.Update { + private MonitoringInstanceInner innerObject; + + private final com.azure.resourcemanager.scom.ScomManager 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 MonitoringInstanceProperties properties() { + return this.innerModel().properties(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public ManagedIdentity identity() { + return this.innerModel().identity(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public MonitoringInstanceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.scom.ScomManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String instanceName; + + private Boolean createValidationMode; + + private MonitoringInstancePatch updateMonitoringInstance; + + public MonitoringInstanceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public MonitoringInstance create() { + this.innerObject = + serviceManager + .serviceClient() + .getInstances() + .createOrUpdate(resourceGroupName, instanceName, this.innerModel(), createValidationMode, Context.NONE); + return this; + } + + public MonitoringInstance create(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getInstances() + .createOrUpdate(resourceGroupName, instanceName, this.innerModel(), createValidationMode, context); + return this; + } + + MonitoringInstanceImpl(String name, com.azure.resourcemanager.scom.ScomManager serviceManager) { + this.innerObject = new MonitoringInstanceInner(); + this.serviceManager = serviceManager; + this.instanceName = name; + this.createValidationMode = null; + } + + public MonitoringInstanceImpl update() { + this.updateMonitoringInstance = new MonitoringInstancePatch(); + return this; + } + + public MonitoringInstance apply() { + this.innerObject = + serviceManager + .serviceClient() + .getInstances() + .update(resourceGroupName, instanceName, updateMonitoringInstance, Context.NONE); + return this; + } + + public MonitoringInstance apply(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getInstances() + .update(resourceGroupName, instanceName, updateMonitoringInstance, context); + return this; + } + + MonitoringInstanceImpl( + MonitoringInstanceInner innerObject, com.azure.resourcemanager.scom.ScomManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.instanceName = Utils.getValueFromIdByName(innerObject.id(), "managedInstances"); + } + + public MonitoringInstance refresh() { + this.innerObject = + serviceManager + .serviceClient() + .getInstances() + .getByResourceGroupWithResponse(resourceGroupName, instanceName, Context.NONE) + .getValue(); + return this; + } + + public MonitoringInstance refresh(Context context) { + this.innerObject = + serviceManager + .serviceClient() + .getInstances() + .getByResourceGroupWithResponse(resourceGroupName, instanceName, context) + .getValue(); + return this; + } + + public void scale(ScalingProperties body) { + serviceManager.instances().scale(resourceGroupName, instanceName, body); + } + + public void scale(ScalingProperties body, Context context) { + serviceManager.instances().scale(resourceGroupName, instanceName, body, context); + } + + public void patchServers() { + serviceManager.instances().patchServers(resourceGroupName, instanceName); + } + + public void patchServers(Context context) { + serviceManager.instances().patchServers(resourceGroupName, instanceName, context); + } + + public MonitoringInstanceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public MonitoringInstanceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public MonitoringInstanceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateMonitoringInstance.withTags(tags); + return this; + } + } + + public MonitoringInstanceImpl withProperties(MonitoringInstanceProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public MonitoringInstanceImpl withIdentity(ManagedIdentity identity) { + this.innerModel().withIdentity(identity); + return this; + } + + public MonitoringInstanceImpl withValidationMode(Boolean validationMode) { + this.createValidationMode = validationMode; + return this; + } + + private boolean isInCreateMode() { + return this.innerModel().id() == null; + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationImpl.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationImpl.java new file mode 100644 index 000000000000..952015ea5129 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationImpl.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.implementation; + +import com.azure.resourcemanager.scom.fluent.models.OperationInner; +import com.azure.resourcemanager.scom.models.Operation; +import com.azure.resourcemanager.scom.models.OperationDisplay; +import com.azure.resourcemanager.scom.models.OperationOrigin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.scom.ScomManager serviceManager; + + OperationImpl(OperationInner innerObject, com.azure.resourcemanager.scom.ScomManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public OperationOrigin origin() { + return this.innerModel().origin(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.scom.ScomManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationsClientImpl.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..a635bc81ae9f --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationsClientImpl.java @@ -0,0 +1,316 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.scom.fluent.OperationsClient; +import com.azure.resourcemanager.scom.fluent.models.OperationInner; +import com.azure.resourcemanager.scom.models.OperationsList; +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 AzureApiForManagingScomMonitoringInstancesImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(AzureApiForManagingScomMonitoringInstancesImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for AzureApiForManagingScomMonitoringInstancesOperations to be used by + * the proxy service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "AzureApiForManagingS") + public interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Scom/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @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 available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations 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.getSubscriptionId(), + resourceGroupName, + 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 available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations 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.getSubscriptionId(), + resourceGroupName, + this.client.getApiVersion(), + accept, + context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), + res.getStatusCode(), + res.getHeaders(), + res.getValue().value(), + res.getValue().nextLink(), + null)); + } + + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName, Context context) { + return new PagedFlux<>( + () -> listByResourceGroupSinglePageAsync(resourceGroupName, context), + nextLink -> listNextSinglePageAsync(nextLink, context)); + } + + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName)); + } + + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + return new PagedIterable<>(listByResourceGroupAsync(resourceGroupName, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items + *

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 list of 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 URL to get the next list of items + *

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 list of 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/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationsImpl.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationsImpl.java new file mode 100644 index 000000000000..92e8d4dcef22 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/OperationsImpl.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.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.scom.fluent.OperationsClient; +import com.azure.resourcemanager.scom.fluent.models.OperationInner; +import com.azure.resourcemanager.scom.models.Operation; +import com.azure.resourcemanager.scom.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.scom.ScomManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, com.azure.resourcemanager.scom.ScomManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return Utils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.scom.ScomManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/Utils.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/Utils.java new file mode 100644 index 000000000000..a793e5d9023f --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/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.scom.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/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/package-info.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/implementation/package-info.java new file mode 100644 index 000000000000..9f1eb9771f7f --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/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 AzureApiForManagingScomMonitoringInstances. SCOM monitoring instance + * management APIs. + */ +package com.azure.resourcemanager.scom.implementation; diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/AzureHybridBenefitProperties.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/AzureHybridBenefitProperties.java new file mode 100644 index 000000000000..c56f5d0d593d --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/AzureHybridBenefitProperties.java @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The properties to maximize savings by using Azure Hybrid Benefit. */ +@Fluent +public final class AzureHybridBenefitProperties { + /* + * SCOM license type. Maximize savings by using license you already own + */ + @JsonProperty(value = "scomLicenseType") + private HybridLicenseType scomLicenseType; + + /* + * Specifies that the image or disk that is being used was licensed on-premises.

For more information, see + * [Azure Hybrid Use Benefit for Windows + * Server](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-hybrid-use-benefit-licensing?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json) + */ + @JsonProperty(value = "windowsServerLicenseType") + private HybridLicenseType windowsServerLicenseType; + + /* + * SQL Server license type. Maximize savings by using Azure Hybrid Benefit for SQL Server with license you already + * own + */ + @JsonProperty(value = "sqlServerLicenseType") + private HybridLicenseType sqlServerLicenseType; + + /** Creates an instance of AzureHybridBenefitProperties class. */ + public AzureHybridBenefitProperties() { + } + + /** + * Get the scomLicenseType property: SCOM license type. Maximize savings by using license you already own. + * + * @return the scomLicenseType value. + */ + public HybridLicenseType scomLicenseType() { + return this.scomLicenseType; + } + + /** + * Set the scomLicenseType property: SCOM license type. Maximize savings by using license you already own. + * + * @param scomLicenseType the scomLicenseType value to set. + * @return the AzureHybridBenefitProperties object itself. + */ + public AzureHybridBenefitProperties withScomLicenseType(HybridLicenseType scomLicenseType) { + this.scomLicenseType = scomLicenseType; + return this; + } + + /** + * Get the windowsServerLicenseType property: Specifies that the image or disk that is being used was licensed + * on-premises. <br><br> For more information, see [Azure Hybrid Use Benefit for Windows + * Server](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-hybrid-use-benefit-licensing?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json). + * + * @return the windowsServerLicenseType value. + */ + public HybridLicenseType windowsServerLicenseType() { + return this.windowsServerLicenseType; + } + + /** + * Set the windowsServerLicenseType property: Specifies that the image or disk that is being used was licensed + * on-premises. <br><br> For more information, see [Azure Hybrid Use Benefit for Windows + * Server](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-windows-hybrid-use-benefit-licensing?toc=%2fazure%2fvirtual-machines%2fwindows%2ftoc.json). + * + * @param windowsServerLicenseType the windowsServerLicenseType value to set. + * @return the AzureHybridBenefitProperties object itself. + */ + public AzureHybridBenefitProperties withWindowsServerLicenseType(HybridLicenseType windowsServerLicenseType) { + this.windowsServerLicenseType = windowsServerLicenseType; + return this; + } + + /** + * Get the sqlServerLicenseType property: SQL Server license type. Maximize savings by using Azure Hybrid Benefit + * for SQL Server with license you already own. + * + * @return the sqlServerLicenseType value. + */ + public HybridLicenseType sqlServerLicenseType() { + return this.sqlServerLicenseType; + } + + /** + * Set the sqlServerLicenseType property: SQL Server license type. Maximize savings by using Azure Hybrid Benefit + * for SQL Server with license you already own. + * + * @param sqlServerLicenseType the sqlServerLicenseType value to set. + * @return the AzureHybridBenefitProperties object itself. + */ + public AzureHybridBenefitProperties withSqlServerLicenseType(HybridLicenseType sqlServerLicenseType) { + this.sqlServerLicenseType = sqlServerLicenseType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DatabaseInstanceProperties.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DatabaseInstanceProperties.java new file mode 100644 index 000000000000..a486c5d51048 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DatabaseInstanceProperties.java @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The properties of database instance. */ +@Fluent +public final class DatabaseInstanceProperties { + /* + * Resource Id of existing database instance + */ + @JsonProperty(value = "databaseInstanceId") + private String databaseInstanceId; + + /* + * Fully qualified domain name of existing database instance + */ + @JsonProperty(value = "databaseFqdn", access = JsonProperty.Access.WRITE_ONLY) + private String databaseFqdn; + + /* + * Name of warehouse database on database instance + */ + @JsonProperty(value = "dwDatabaseName", access = JsonProperty.Access.WRITE_ONLY) + private String dwDatabaseName; + + /* + * Resource Id of operational database on database instance + */ + @JsonProperty(value = "operationalDatabaseId", access = JsonProperty.Access.WRITE_ONLY) + private String operationalDatabaseId; + + /* + * Resource Id of warehouse database on database instance + */ + @JsonProperty(value = "dwDatabaseId", access = JsonProperty.Access.WRITE_ONLY) + private String dwDatabaseId; + + /** Creates an instance of DatabaseInstanceProperties class. */ + public DatabaseInstanceProperties() { + } + + /** + * Get the databaseInstanceId property: Resource Id of existing database instance. + * + * @return the databaseInstanceId value. + */ + public String databaseInstanceId() { + return this.databaseInstanceId; + } + + /** + * Set the databaseInstanceId property: Resource Id of existing database instance. + * + * @param databaseInstanceId the databaseInstanceId value to set. + * @return the DatabaseInstanceProperties object itself. + */ + public DatabaseInstanceProperties withDatabaseInstanceId(String databaseInstanceId) { + this.databaseInstanceId = databaseInstanceId; + return this; + } + + /** + * Get the databaseFqdn property: Fully qualified domain name of existing database instance. + * + * @return the databaseFqdn value. + */ + public String databaseFqdn() { + return this.databaseFqdn; + } + + /** + * Get the dwDatabaseName property: Name of warehouse database on database instance. + * + * @return the dwDatabaseName value. + */ + public String dwDatabaseName() { + return this.dwDatabaseName; + } + + /** + * Get the operationalDatabaseId property: Resource Id of operational database on database instance. + * + * @return the operationalDatabaseId value. + */ + public String operationalDatabaseId() { + return this.operationalDatabaseId; + } + + /** + * Get the dwDatabaseId property: Resource Id of warehouse database on database instance. + * + * @return the dwDatabaseId value. + */ + public String dwDatabaseId() { + return this.dwDatabaseId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DomainControllerProperties.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DomainControllerProperties.java new file mode 100644 index 000000000000..6ea01ee13819 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DomainControllerProperties.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The properties of domain controller to which SCOM and SQL servers join for AuthN/AuthZ. */ +@Fluent +public final class DomainControllerProperties { + /* + * Fully qualified domain name + */ + @JsonProperty(value = "domainName") + private String domainName; + + /* + * IP address of DNS server + */ + @JsonProperty(value = "dnsServer") + private String dnsServer; + + /* + * Organizational Unit path in which the SCOM servers will be present + */ + @JsonProperty(value = "ouPath") + private String ouPath; + + /** Creates an instance of DomainControllerProperties class. */ + public DomainControllerProperties() { + } + + /** + * Get the domainName property: Fully qualified domain name. + * + * @return the domainName value. + */ + public String domainName() { + return this.domainName; + } + + /** + * Set the domainName property: Fully qualified domain name. + * + * @param domainName the domainName value to set. + * @return the DomainControllerProperties object itself. + */ + public DomainControllerProperties withDomainName(String domainName) { + this.domainName = domainName; + return this; + } + + /** + * Get the dnsServer property: IP address of DNS server. + * + * @return the dnsServer value. + */ + public String dnsServer() { + return this.dnsServer; + } + + /** + * Set the dnsServer property: IP address of DNS server. + * + * @param dnsServer the dnsServer value to set. + * @return the DomainControllerProperties object itself. + */ + public DomainControllerProperties withDnsServer(String dnsServer) { + this.dnsServer = dnsServer; + return this; + } + + /** + * Get the ouPath property: Organizational Unit path in which the SCOM servers will be present. + * + * @return the ouPath value. + */ + public String ouPath() { + return this.ouPath; + } + + /** + * Set the ouPath property: Organizational Unit path in which the SCOM servers will be present. + * + * @param ouPath the ouPath value to set. + * @return the DomainControllerProperties object itself. + */ + public DomainControllerProperties withOuPath(String ouPath) { + this.ouPath = ouPath; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DomainUserCredentials.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DomainUserCredentials.java new file mode 100644 index 000000000000..b60ac6b15d7b --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/DomainUserCredentials.java @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Get Domain user name and password from key vault. */ +@Fluent +public final class DomainUserCredentials { + /* + * Key vault url to get the domain username and password + */ + @JsonProperty(value = "keyVaultUrl") + private String keyVaultUrl; + + /* + * Domain user name secret + */ + @JsonProperty(value = "userNameSecret") + private String usernameSecret; + + /* + * Domain Password secret + */ + @JsonProperty(value = "passwordSecret") + private String passwordSecret; + + /** Creates an instance of DomainUserCredentials class. */ + public DomainUserCredentials() { + } + + /** + * Get the keyVaultUrl property: Key vault url to get the domain username and password. + * + * @return the keyVaultUrl value. + */ + public String keyVaultUrl() { + return this.keyVaultUrl; + } + + /** + * Set the keyVaultUrl property: Key vault url to get the domain username and password. + * + * @param keyVaultUrl the keyVaultUrl value to set. + * @return the DomainUserCredentials object itself. + */ + public DomainUserCredentials withKeyVaultUrl(String keyVaultUrl) { + this.keyVaultUrl = keyVaultUrl; + return this; + } + + /** + * Get the usernameSecret property: Domain user name secret. + * + * @return the usernameSecret value. + */ + public String usernameSecret() { + return this.usernameSecret; + } + + /** + * Set the usernameSecret property: Domain user name secret. + * + * @param usernameSecret the usernameSecret value to set. + * @return the DomainUserCredentials object itself. + */ + public DomainUserCredentials withUsernameSecret(String usernameSecret) { + this.usernameSecret = usernameSecret; + return this; + } + + /** + * Get the passwordSecret property: Domain Password secret. + * + * @return the passwordSecret value. + */ + public String passwordSecret() { + return this.passwordSecret; + } + + /** + * Set the passwordSecret property: Domain Password secret. + * + * @param passwordSecret the passwordSecret value to set. + * @return the DomainUserCredentials object itself. + */ + public DomainUserCredentials withPasswordSecret(String passwordSecret) { + this.passwordSecret = passwordSecret; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/GmsaDetails.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/GmsaDetails.java new file mode 100644 index 000000000000..fe100ac71d8f --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/GmsaDetails.java @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Gmsa Details. */ +@Fluent +public final class GmsaDetails { + /* + * Frontend IP configuration for Load Balancer, which should be an available IP in customer VNet + */ + @JsonProperty(value = "loadBalancerIP") + private String loadBalancerIp; + + /* + * gMSA account under which context all Management Server services will run + */ + @JsonProperty(value = "gmsaAccount") + private String gmsaAccount; + + /* + * OnPrem AD Computer Group where we will join VMs for ease of management + */ + @JsonProperty(value = "managementServerGroupName") + private String managementServerGroupName; + + /* + * Frontend DNS name for Load Balancer which will be used by Agents to initiate communication + */ + @JsonProperty(value = "dnsName") + private String dnsName; + + /** Creates an instance of GmsaDetails class. */ + public GmsaDetails() { + } + + /** + * Get the loadBalancerIp property: Frontend IP configuration for Load Balancer, which should be an available IP in + * customer VNet. + * + * @return the loadBalancerIp value. + */ + public String loadBalancerIp() { + return this.loadBalancerIp; + } + + /** + * Set the loadBalancerIp property: Frontend IP configuration for Load Balancer, which should be an available IP in + * customer VNet. + * + * @param loadBalancerIp the loadBalancerIp value to set. + * @return the GmsaDetails object itself. + */ + public GmsaDetails withLoadBalancerIp(String loadBalancerIp) { + this.loadBalancerIp = loadBalancerIp; + return this; + } + + /** + * Get the gmsaAccount property: gMSA account under which context all Management Server services will run. + * + * @return the gmsaAccount value. + */ + public String gmsaAccount() { + return this.gmsaAccount; + } + + /** + * Set the gmsaAccount property: gMSA account under which context all Management Server services will run. + * + * @param gmsaAccount the gmsaAccount value to set. + * @return the GmsaDetails object itself. + */ + public GmsaDetails withGmsaAccount(String gmsaAccount) { + this.gmsaAccount = gmsaAccount; + return this; + } + + /** + * Get the managementServerGroupName property: OnPrem AD Computer Group where we will join VMs for ease of + * management. + * + * @return the managementServerGroupName value. + */ + public String managementServerGroupName() { + return this.managementServerGroupName; + } + + /** + * Set the managementServerGroupName property: OnPrem AD Computer Group where we will join VMs for ease of + * management. + * + * @param managementServerGroupName the managementServerGroupName value to set. + * @return the GmsaDetails object itself. + */ + public GmsaDetails withManagementServerGroupName(String managementServerGroupName) { + this.managementServerGroupName = managementServerGroupName; + return this; + } + + /** + * Get the dnsName property: Frontend DNS name for Load Balancer which will be used by Agents to initiate + * communication. + * + * @return the dnsName value. + */ + public String dnsName() { + return this.dnsName; + } + + /** + * Set the dnsName property: Frontend DNS name for Load Balancer which will be used by Agents to initiate + * communication. + * + * @param dnsName the dnsName value to set. + * @return the GmsaDetails object itself. + */ + public GmsaDetails withDnsName(String dnsName) { + this.dnsName = dnsName; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/HybridLicenseType.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/HybridLicenseType.java new file mode 100644 index 000000000000..5db81757f214 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/HybridLicenseType.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.scom.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** License type for various SCOM infra components. */ +public final class HybridLicenseType extends ExpandableStringEnum { + /** Static value None for HybridLicenseType. */ + public static final HybridLicenseType NONE = fromString("None"); + + /** Static value AzureHybridBenefit for HybridLicenseType. */ + public static final HybridLicenseType AZURE_HYBRID_BENEFIT = fromString("AzureHybridBenefit"); + + /** + * Creates a new instance of HybridLicenseType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public HybridLicenseType() { + } + + /** + * Creates or finds a HybridLicenseType from its string representation. + * + * @param name a name to look for. + * @return the corresponding HybridLicenseType. + */ + @JsonCreator + public static HybridLicenseType fromString(String name) { + return fromString(name, HybridLicenseType.class); + } + + /** + * Gets known HybridLicenseType values. + * + * @return known HybridLicenseType values. + */ + public static Collection values() { + return values(HybridLicenseType.class); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Instances.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Instances.java new file mode 100644 index 000000000000..4be554d72ac1 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Instances.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.scom.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 Instances. */ +public interface Instances { + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists all SCOM monitoring instances in a resource group. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * Lists all SCOM monitoring instances 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 a paged list of SCOM monitoring instances as paginated response with {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details along with {@link Response}. + */ + Response getByResourceGroupWithResponse( + String resourceGroupName, String instanceName, Context context); + + /** + * Get SCOM monitoring instance details. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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 sCOM monitoring instance details. + */ + MonitoringInstance getByResourceGroup(String resourceGroupName, String instanceName); + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String instanceName); + + /** + * Delete a SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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. + */ + void delete(String resourceGroupName, String instanceName, Context context); + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void scale(String resourceGroupName, String instanceName, ScalingProperties body); + + /** + * Scaling SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @param body Properties for Scaling. + * @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. + */ + void scale(String resourceGroupName, String instanceName, ScalingProperties body, Context context); + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void patchServers(String resourceGroupName, String instanceName); + + /** + * Update SCOM servers with latest scom software. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param instanceName Name of the SCOM monitoring instance. + * @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. + */ + void patchServers(String resourceGroupName, String instanceName, Context context); + + /** + * Get SCOM monitoring instance details. + * + * @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 sCOM monitoring instance details along with {@link Response}. + */ + MonitoringInstance getById(String id); + + /** + * Get SCOM monitoring instance details. + * + * @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 sCOM monitoring instance details along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Delete a SCOM monitoring instance. + * + * @param id the resource ID. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteById(String id); + + /** + * Delete a SCOM monitoring instance. + * + * @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. + */ + void deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new MonitoringInstance resource. + * + * @param name resource name. + * @return the first stage of the new MonitoringInstance definition. + */ + MonitoringInstance.DefinitionStages.Blank define(String name); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedIdentity.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedIdentity.java new file mode 100644 index 000000000000..550075a672d7 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedIdentity.java @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; +import java.util.UUID; + +/** Azure Active Directory identity configuration for a resource. */ +@Fluent +public final class ManagedIdentity { + /* + * The identity type + */ + @JsonProperty(value = "type") + private ManagedIdentityType type; + + /* + * System Assigned Identity ObjectId. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private UUID principalId; + + /* + * The Azure Active Directory tenant id. + */ + @JsonProperty(value = "tenantId", access = JsonProperty.Access.WRITE_ONLY) + private String tenantId; + + /* + * The resource ids of the user assigned identities to use + */ + @JsonProperty(value = "userAssignedIdentities") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map userAssignedIdentities; + + /** Creates an instance of ManagedIdentity class. */ + public ManagedIdentity() { + } + + /** + * Get the type property: The identity type. + * + * @return the type value. + */ + public ManagedIdentityType type() { + return this.type; + } + + /** + * Set the type property: The identity type. + * + * @param type the type value to set. + * @return the ManagedIdentity object itself. + */ + public ManagedIdentity withType(ManagedIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the principalId property: System Assigned Identity ObjectId. + * + * @return the principalId value. + */ + public UUID principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The Azure Active Directory tenant id. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the userAssignedIdentities property: The resource ids of the user assigned identities to use. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The resource ids of the user assigned identities to use. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedIdentity object itself. + */ + public ManagedIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (userAssignedIdentities() != null) { + userAssignedIdentities() + .values() + .forEach( + e -> { + if (e != null) { + e.validate(); + } + }); + } + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedIdentityType.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedIdentityType.java new file mode 100644 index 000000000000..45e43368f0e1 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedIdentityType.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** The identity type. */ +public final class ManagedIdentityType extends ExpandableStringEnum { + /** Static value None for ManagedIdentityType. */ + public static final ManagedIdentityType NONE = fromString("None"); + + /** Static value UserAssigned for ManagedIdentityType. */ + public static final ManagedIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** Static value SystemAssigned for ManagedIdentityType. */ + public static final ManagedIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** Static value SystemAssigned,UserAssigned for ManagedIdentityType. */ + public static final ManagedIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedIdentityType() { + } + + /** + * Creates or finds a ManagedIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedIdentityType. + */ + @JsonCreator + public static ManagedIdentityType fromString(String name) { + return fromString(name, ManagedIdentityType.class); + } + + /** + * Gets known ManagedIdentityType values. + * + * @return known ManagedIdentityType values. + */ + public static Collection values() { + return values(ManagedIdentityType.class); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedInstanceOperationStatus.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedInstanceOperationStatus.java new file mode 100644 index 000000000000..6d74344f92a6 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagedInstanceOperationStatus.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Gets status of current and latest SCOM managed instance Operation. */ +@Immutable +public final class ManagedInstanceOperationStatus { + /* + * Operation Name + */ + @JsonProperty(value = "operationName", access = JsonProperty.Access.WRITE_ONLY) + private String operationName; + + /* + * Operation status + */ + @JsonProperty(value = "operationState", access = JsonProperty.Access.WRITE_ONLY) + private String operationState; + + /** Creates an instance of ManagedInstanceOperationStatus class. */ + public ManagedInstanceOperationStatus() { + } + + /** + * Get the operationName property: Operation Name. + * + * @return the operationName value. + */ + public String operationName() { + return this.operationName; + } + + /** + * Get the operationState property: Operation status. + * + * @return the operationState value. + */ + public String operationState() { + return this.operationState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagementServerProperties.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagementServerProperties.java new file mode 100644 index 000000000000..aad07d74d7ae --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ManagementServerProperties.java @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The properties of management server. */ +@Immutable +public final class ManagementServerProperties { + /* + * Management server Name + */ + @JsonProperty(value = "serverName", access = JsonProperty.Access.WRITE_ONLY) + private String serverName; + + /* + * Azure VM Resource Id of the Management server + */ + @JsonProperty(value = "vmResId", access = JsonProperty.Access.WRITE_ONLY) + private String vmResId; + + /* + * Management server Fully Qualified Domain Name + */ + @JsonProperty(value = "fqdn", access = JsonProperty.Access.WRITE_ONLY) + private String fqdn; + + /* + * Represent whether the Server is a Management Server and/or Web Console Server + */ + @JsonProperty(value = "serverRoles", access = JsonProperty.Access.WRITE_ONLY) + private String serverRoles; + + /* + * Management server health state + */ + @JsonProperty(value = "healthState", access = JsonProperty.Access.WRITE_ONLY) + private String healthState; + + /** Creates an instance of ManagementServerProperties class. */ + public ManagementServerProperties() { + } + + /** + * Get the serverName property: Management server Name. + * + * @return the serverName value. + */ + public String serverName() { + return this.serverName; + } + + /** + * Get the vmResId property: Azure VM Resource Id of the Management server. + * + * @return the vmResId value. + */ + public String vmResId() { + return this.vmResId; + } + + /** + * Get the fqdn property: Management server Fully Qualified Domain Name. + * + * @return the fqdn value. + */ + public String fqdn() { + return this.fqdn; + } + + /** + * Get the serverRoles property: Represent whether the Server is a Management Server and/or Web Console Server. + * + * @return the serverRoles value. + */ + public String serverRoles() { + return this.serverRoles; + } + + /** + * Get the healthState property: Management server health state. + * + * @return the healthState value. + */ + public String healthState() { + return this.healthState; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstance.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstance.java new file mode 100644 index 000000000000..32fdac81a611 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstance.java @@ -0,0 +1,305 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.scom.fluent.models.MonitoringInstanceInner; +import java.util.Map; + +/** An immutable client-side representation of MonitoringInstance. */ +public interface MonitoringInstance { + /** + * 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 properties property: The properties of a SCOM instance resource. + * + * @return the properties value. + */ + MonitoringInstanceProperties properties(); + + /** + * Gets the systemData property: The system data. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * Gets the identity property: The Azure Active Directory identity of the SCOM instance. + * + * @return the identity value. + */ + ManagedIdentity identity(); + + /** + * 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 name of the resource group. + * + * @return the name of the resource group. + */ + String resourceGroupName(); + + /** + * Gets the inner com.azure.resourcemanager.scom.fluent.models.MonitoringInstanceInner object. + * + * @return the inner object. + */ + MonitoringInstanceInner innerModel(); + + /** The entirety of the MonitoringInstance definition. */ + interface Definition + extends DefinitionStages.Blank, + DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, + DefinitionStages.WithCreate { + } + + /** The MonitoringInstance definition stages. */ + interface DefinitionStages { + /** The first stage of the MonitoringInstance definition. */ + interface Blank extends WithLocation { + } + + /** The stage of the MonitoringInstance 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 MonitoringInstance definition allowing to specify parent resource. */ + interface WithResourceGroup { + /** + * Specifies resourceGroupName. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @return the next definition stage. + */ + WithCreate withExistingResourceGroup(String resourceGroupName); + } + + /** + * The stage of the MonitoringInstance 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.WithProperties, + DefinitionStages.WithIdentity, + DefinitionStages.WithValidationMode { + /** + * Executes the create request. + * + * @return the created resource. + */ + MonitoringInstance create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + MonitoringInstance create(Context context); + } + + /** The stage of the MonitoringInstance 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 MonitoringInstance definition allowing to specify properties. */ + interface WithProperties { + /** + * Specifies the properties property: The properties of a SCOM instance resource. + * + * @param properties The properties of a SCOM instance resource. + * @return the next definition stage. + */ + WithCreate withProperties(MonitoringInstanceProperties properties); + } + + /** The stage of the MonitoringInstance definition allowing to specify identity. */ + interface WithIdentity { + /** + * Specifies the identity property: The Azure Active Directory identity of the SCOM instance. + * + * @param identity The Azure Active Directory identity of the SCOM instance. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedIdentity identity); + } + + /** The stage of the MonitoringInstance definition allowing to specify validationMode. */ + interface WithValidationMode { + /** + * Specifies the validationMode property: Validation mode for the SCOM monitoring instance. + * + * @param validationMode Validation mode for the SCOM monitoring instance. + * @return the next definition stage. + */ + WithCreate withValidationMode(Boolean validationMode); + } + } + + /** + * Begins update for the MonitoringInstance resource. + * + * @return the stage of resource update. + */ + MonitoringInstance.Update update(); + + /** The template for MonitoringInstance update. */ + interface Update extends UpdateStages.WithTags { + /** + * Executes the update request. + * + * @return the updated resource. + */ + MonitoringInstance apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + MonitoringInstance apply(Context context); + } + + /** The MonitoringInstance update stages. */ + interface UpdateStages { + /** The stage of the MonitoringInstance update allowing to specify tags. */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + MonitoringInstance refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + MonitoringInstance refresh(Context context); + + /** + * Scaling SCOM monitoring instance. + * + * @param body Properties for Scaling. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void scale(ScalingProperties body); + + /** + * Scaling SCOM monitoring instance. + * + * @param body Properties for Scaling. + * @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. + */ + void scale(ScalingProperties body, Context context); + + /** + * Update SCOM servers with latest scom software. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void patchServers(); + + /** + * Update SCOM servers with latest scom software. + * + * @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. + */ + void patchServers(Context context); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstanceList.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstanceList.java new file mode 100644 index 000000000000..4b59a78614e8 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstanceList.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Immutable; +import com.azure.resourcemanager.scom.fluent.models.MonitoringInstanceInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** A paged list of SCOM monitoring instances. */ +@Immutable +public final class MonitoringInstanceList { + /* + * The items on the page + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private List value; + + /* + * URL to get the next page if any + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** Creates an instance of MonitoringInstanceList class. */ + public MonitoringInstanceList() { + } + + /** + * Get the value property: The items on the page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: URL to get the next page if 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/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstancePatch.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstancePatch.java new file mode 100644 index 000000000000..83b4bacf84f9 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstancePatch.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +/** Object containing updates for patch operations. */ +@Fluent +public final class MonitoringInstancePatch { + /* + * The Azure Active Directory identity of the SCOM instance + */ + @JsonProperty(value = "identity") + private ManagedIdentity identity; + + /* + * Resource tags. + */ + @JsonProperty(value = "tags") + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + private Map tags; + + /** Creates an instance of MonitoringInstancePatch class. */ + public MonitoringInstancePatch() { + } + + /** + * Get the identity property: The Azure Active Directory identity of the SCOM instance. + * + * @return the identity value. + */ + public ManagedIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The Azure Active Directory identity of the SCOM instance. + * + * @param identity the identity value to set. + * @return the MonitoringInstancePatch object itself. + */ + public MonitoringInstancePatch withIdentity(ManagedIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the tags property: Resource tags. + * + * @return the tags value. + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags property: Resource tags. + * + * @param tags the tags value to set. + * @return the MonitoringInstancePatch object itself. + */ + public MonitoringInstancePatch withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (identity() != null) { + identity().validate(); + } + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstanceProperties.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstanceProperties.java new file mode 100644 index 000000000000..23a6d5f1400a --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/MonitoringInstanceProperties.java @@ -0,0 +1,266 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** The properties of a SCOM instance resource. */ +@Fluent +public final class MonitoringInstanceProperties { + /* + * SCOM product version to be installed on instance + */ + @JsonProperty(value = "productVersion", access = JsonProperty.Access.WRITE_ONLY) + private String productVersion; + + /* + * Virtual Network subnet id on which Aquila instance will be provisioned + */ + @JsonProperty(value = "vNetSubnetId") + private String vNetSubnetId; + + /* + * List of management server endpoints + */ + @JsonProperty(value = "managementEndpoints", access = JsonProperty.Access.WRITE_ONLY) + private List managementEndpoints; + + /* + * Database instance on which SCOM Operational and Warehouse database will be stored + */ + @JsonProperty(value = "databaseInstance") + private DatabaseInstanceProperties databaseInstance; + + /* + * Domain controller details + */ + @JsonProperty(value = "domainController") + private DomainControllerProperties domainController; + + /* + * Domain user which will be used to join VMs to domain and login to VMs + */ + @JsonProperty(value = "domainUserCredentials") + private DomainUserCredentials domainUserCredentials; + + /* + * Gmsa Details for load balancer and vmss + */ + @JsonProperty(value = "gmsaDetails") + private GmsaDetails gmsaDetails; + + /* + * The properties to enable Azure Hybrid benefit for various SCOM infrastructure license + */ + @JsonProperty(value = "azureHybridBenefit") + private AzureHybridBenefitProperties azureHybridBenefit; + + /* + * Gets or sets the provisioning state. + */ + @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY) + private String provisioningState; + + /* + * Gets status of current and latest SCOM managed instance Operations + */ + @JsonProperty(value = "operationsStatus", access = JsonProperty.Access.WRITE_ONLY) + private List operationsStatus; + + /** Creates an instance of MonitoringInstanceProperties class. */ + public MonitoringInstanceProperties() { + } + + /** + * Get the productVersion property: SCOM product version to be installed on instance. + * + * @return the productVersion value. + */ + public String productVersion() { + return this.productVersion; + } + + /** + * Get the vNetSubnetId property: Virtual Network subnet id on which Aquila instance will be provisioned. + * + * @return the vNetSubnetId value. + */ + public String vNetSubnetId() { + return this.vNetSubnetId; + } + + /** + * Set the vNetSubnetId property: Virtual Network subnet id on which Aquila instance will be provisioned. + * + * @param vNetSubnetId the vNetSubnetId value to set. + * @return the MonitoringInstanceProperties object itself. + */ + public MonitoringInstanceProperties withVNetSubnetId(String vNetSubnetId) { + this.vNetSubnetId = vNetSubnetId; + return this; + } + + /** + * Get the managementEndpoints property: List of management server endpoints. + * + * @return the managementEndpoints value. + */ + public List managementEndpoints() { + return this.managementEndpoints; + } + + /** + * Get the databaseInstance property: Database instance on which SCOM Operational and Warehouse database will be + * stored. + * + * @return the databaseInstance value. + */ + public DatabaseInstanceProperties databaseInstance() { + return this.databaseInstance; + } + + /** + * Set the databaseInstance property: Database instance on which SCOM Operational and Warehouse database will be + * stored. + * + * @param databaseInstance the databaseInstance value to set. + * @return the MonitoringInstanceProperties object itself. + */ + public MonitoringInstanceProperties withDatabaseInstance(DatabaseInstanceProperties databaseInstance) { + this.databaseInstance = databaseInstance; + return this; + } + + /** + * Get the domainController property: Domain controller details. + * + * @return the domainController value. + */ + public DomainControllerProperties domainController() { + return this.domainController; + } + + /** + * Set the domainController property: Domain controller details. + * + * @param domainController the domainController value to set. + * @return the MonitoringInstanceProperties object itself. + */ + public MonitoringInstanceProperties withDomainController(DomainControllerProperties domainController) { + this.domainController = domainController; + return this; + } + + /** + * Get the domainUserCredentials property: Domain user which will be used to join VMs to domain and login to VMs. + * + * @return the domainUserCredentials value. + */ + public DomainUserCredentials domainUserCredentials() { + return this.domainUserCredentials; + } + + /** + * Set the domainUserCredentials property: Domain user which will be used to join VMs to domain and login to VMs. + * + * @param domainUserCredentials the domainUserCredentials value to set. + * @return the MonitoringInstanceProperties object itself. + */ + public MonitoringInstanceProperties withDomainUserCredentials(DomainUserCredentials domainUserCredentials) { + this.domainUserCredentials = domainUserCredentials; + return this; + } + + /** + * Get the gmsaDetails property: Gmsa Details for load balancer and vmss. + * + * @return the gmsaDetails value. + */ + public GmsaDetails gmsaDetails() { + return this.gmsaDetails; + } + + /** + * Set the gmsaDetails property: Gmsa Details for load balancer and vmss. + * + * @param gmsaDetails the gmsaDetails value to set. + * @return the MonitoringInstanceProperties object itself. + */ + public MonitoringInstanceProperties withGmsaDetails(GmsaDetails gmsaDetails) { + this.gmsaDetails = gmsaDetails; + return this; + } + + /** + * Get the azureHybridBenefit property: The properties to enable Azure Hybrid benefit for various SCOM + * infrastructure license. + * + * @return the azureHybridBenefit value. + */ + public AzureHybridBenefitProperties azureHybridBenefit() { + return this.azureHybridBenefit; + } + + /** + * Set the azureHybridBenefit property: The properties to enable Azure Hybrid benefit for various SCOM + * infrastructure license. + * + * @param azureHybridBenefit the azureHybridBenefit value to set. + * @return the MonitoringInstanceProperties object itself. + */ + public MonitoringInstanceProperties withAzureHybridBenefit(AzureHybridBenefitProperties azureHybridBenefit) { + this.azureHybridBenefit = azureHybridBenefit; + return this; + } + + /** + * Get the provisioningState property: Gets or sets the provisioning state. + * + * @return the provisioningState value. + */ + public String provisioningState() { + return this.provisioningState; + } + + /** + * Get the operationsStatus property: Gets status of current and latest SCOM managed instance Operations. + * + * @return the operationsStatus value. + */ + public List operationsStatus() { + return this.operationsStatus; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (managementEndpoints() != null) { + managementEndpoints().forEach(e -> e.validate()); + } + if (databaseInstance() != null) { + databaseInstance().validate(); + } + if (domainController() != null) { + domainController().validate(); + } + if (domainUserCredentials() != null) { + domainUserCredentials().validate(); + } + if (gmsaDetails() != null) { + gmsaDetails().validate(); + } + if (azureHybridBenefit() != null) { + azureHybridBenefit().validate(); + } + if (operationsStatus() != null) { + operationsStatus().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Operation.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Operation.java new file mode 100644 index 000000000000..96094199f0a1 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Operation.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.scom.models; + +import com.azure.resourcemanager.scom.fluent.models.OperationInner; + +/** An immutable client-side representation of Operation. */ +public interface Operation { + /** + * Gets the name property: Name of the operation being performed on this object. + * + * @return the name value. + */ + String name(); + + /** + * Gets the display property: Contains the localized display information for this operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation. + * + * @return the origin value. + */ + OperationOrigin origin(); + + /** + * Gets the inner com.azure.resourcemanager.scom.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationDisplay.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationDisplay.java new file mode 100644 index 000000000000..e37ee5ed442b --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationDisplay.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Contains the localized display information for this operation. */ +@Immutable +public final class OperationDisplay { + /* + * Localized friendly form of the resource provider name + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private String provider; + + /* + * Localized friendly form of the resource type related to this operation + */ + @JsonProperty(value = "resource", access = JsonProperty.Access.WRITE_ONLY) + private String resource; + + /* + * Localized friendly name for the operation + */ + @JsonProperty(value = "operation", access = JsonProperty.Access.WRITE_ONLY) + private String operation; + + /* + * Localized friendly description for the operation + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** Creates an instance of OperationDisplay class. */ + public OperationDisplay() { + } + + /** + * Get the provider property: Localized friendly form of the resource provider name. + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: Localized friendly form of the resource type related to this operation. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: Localized friendly name for the operation. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: Localized friendly description for the operation. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationOrigin.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationOrigin.java new file mode 100644 index 000000000000..687388453764 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationOrigin.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** The intended executor of the operation. */ +public final class OperationOrigin extends ExpandableStringEnum { + /** Static value NotSpecified for OperationOrigin. */ + public static final OperationOrigin NOT_SPECIFIED = fromString("NotSpecified"); + + /** Static value user for OperationOrigin. */ + public static final OperationOrigin USER = fromString("user"); + + /** Static value system for OperationOrigin. */ + public static final OperationOrigin SYSTEM = fromString("system"); + + /** + * Creates a new instance of OperationOrigin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public OperationOrigin() { + } + + /** + * Creates or finds a OperationOrigin from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationOrigin. + */ + @JsonCreator + public static OperationOrigin fromString(String name) { + return fromString(name, OperationOrigin.class); + } + + /** + * Gets known OperationOrigin values. + * + * @return known OperationOrigin values. + */ + public static Collection values() { + return values(OperationOrigin.class); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Operations.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Operations.java new file mode 100644 index 000000000000..5e23487d02bc --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/Operations.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists all available operations on SCOM monitoring instance. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return list of operations as paginated response with {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationsList.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationsList.java new file mode 100644 index 000000000000..e49dcccc1010 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/OperationsList.java @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.azure.resourcemanager.scom.fluent.models.OperationInner; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** List of operations. */ +@Fluent +public final class OperationsList { + /* + * List of operations + */ + @JsonProperty(value = "value") + private List value; + + /* + * URL to get the next page if any + */ + @JsonProperty(value = "nextLink", access = JsonProperty.Access.WRITE_ONLY) + private String nextLink; + + /** Creates an instance of OperationsList class. */ + public OperationsList() { + } + + /** + * Get the value property: List of operations. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of operations. + * + * @param value the value value to set. + * @return the OperationsList object itself. + */ + public OperationsList withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the nextLink property: URL to get the next page if 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/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ScalingProperties.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ScalingProperties.java new file mode 100644 index 000000000000..60f54ac174ef --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/ScalingProperties.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Properties for Scaling. */ +@Fluent +public final class ScalingProperties { + /* + * Required management server count + */ + @JsonProperty(value = "serverCount") + private Long serverCount; + + /** Creates an instance of ScalingProperties class. */ + public ScalingProperties() { + } + + /** + * Get the serverCount property: Required management server count. + * + * @return the serverCount value. + */ + public Long serverCount() { + return this.serverCount; + } + + /** + * Set the serverCount property: Required management server count. + * + * @param serverCount the serverCount value to set. + * @return the ScalingProperties object itself. + */ + public ScalingProperties withServerCount(Long serverCount) { + this.serverCount = serverCount; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/UserIdentity.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/UserIdentity.java new file mode 100644 index 000000000000..b366950e00a8 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/UserIdentity.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.models; + +import com.azure.core.annotation.Immutable; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Azure Active Directory identity configuration for a resource. */ +@Immutable +public final class UserIdentity { + /* + * The Azure Active Directory principal id. + */ + @JsonProperty(value = "principalId", access = JsonProperty.Access.WRITE_ONLY) + private String principalId; + + /* + * The Azure Active Directory client id. + */ + @JsonProperty(value = "clientId", access = JsonProperty.Access.WRITE_ONLY) + private String clientId; + + /** Creates an instance of UserIdentity class. */ + public UserIdentity() { + } + + /** + * Get the principalId property: The Azure Active Directory principal id. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The Azure Active Directory client id. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/package-info.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/models/package-info.java new file mode 100644 index 000000000000..0acbbb2eeeb9 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/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 AzureApiForManagingScomMonitoringInstances. SCOM monitoring instance + * management APIs. + */ +package com.azure.resourcemanager.scom.models; diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/package-info.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/package-info.java new file mode 100644 index 000000000000..d687494533cc --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/main/java/com/azure/resourcemanager/scom/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 AzureApiForManagingScomMonitoringInstances. SCOM monitoring instance management + * APIs. + */ +package com.azure.resourcemanager.scom; diff --git a/sdk/scom/azure-resourcemanager-scom/src/main/java/module-info.java b/sdk/scom/azure-resourcemanager-scom/src/main/java/module-info.java new file mode 100644 index 000000000000..392f4fafbbfa --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/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.scom { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.scom; + exports com.azure.resourcemanager.scom.fluent; + exports com.azure.resourcemanager.scom.fluent.models; + exports com.azure.resourcemanager.scom.models; + + opens com.azure.resourcemanager.scom.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.scom.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesCreateOrUpdateSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesCreateOrUpdateSamples.java new file mode 100644 index 000000000000..a56614a6d613 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesCreateOrUpdateSamples.java @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +import com.azure.resourcemanager.scom.models.AzureHybridBenefitProperties; +import com.azure.resourcemanager.scom.models.DatabaseInstanceProperties; +import com.azure.resourcemanager.scom.models.DomainControllerProperties; +import com.azure.resourcemanager.scom.models.DomainUserCredentials; +import com.azure.resourcemanager.scom.models.GmsaDetails; +import com.azure.resourcemanager.scom.models.HybridLicenseType; +import com.azure.resourcemanager.scom.models.ManagedIdentity; +import com.azure.resourcemanager.scom.models.ManagedIdentityType; +import com.azure.resourcemanager.scom.models.MonitoringInstanceProperties; +import com.azure.resourcemanager.scom.models.UserIdentity; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Instances CreateOrUpdate. */ +public final class InstancesCreateOrUpdateSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Create.json + */ + /** + * Sample code: Instances_CreateOrUpdate. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesCreateOrUpdate(com.azure.resourcemanager.scom.ScomManager manager) { + manager + .instances() + .define("myInstace") + .withRegion("eastus2") + .withExistingResourceGroup("myResGroup") + .withTags(mapOf()) + .withProperties( + new MonitoringInstanceProperties() + .withVNetSubnetId( + "/subscriptions/{subscription-id}/resourceGroups/mySCOMMIGroup/providers/Microsoft.Network/virtualNetworks/vNet2/subnets/default") + .withDatabaseInstance( + new DatabaseInstanceProperties() + .withDatabaseInstanceId( + "/subscriptions/{subscription-id}/resourceGroups/mySCOMMIGroup/providers/Microsoft.sql/managedInstances/inst1")) + .withDomainController( + new DomainControllerProperties().withDomainName("domain.com").withDnsServer("10.10.10.10")) + .withDomainUserCredentials( + new DomainUserCredentials() + .withKeyVaultUrl("fakeTokenPlaceholder") + .withUsernameSecret("fakeTokenPlaceholder") + .withPasswordSecret("fakeTokenPlaceholder")) + .withGmsaDetails( + new GmsaDetails() + .withLoadBalancerIp("10.10.10.10") + .withGmsaAccount("vmsslb2$") + .withManagementServerGroupName("servergroup") + .withDnsName("dnsname.com")) + .withAzureHybridBenefit( + new AzureHybridBenefitProperties() + .withScomLicenseType(HybridLicenseType.NONE) + .withWindowsServerLicenseType(HybridLicenseType.NONE) + .withSqlServerLicenseType(HybridLicenseType.NONE))) + .withIdentity( + new ManagedIdentity() + .withType(ManagedIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED) + .withUserAssignedIdentities( + mapOf( + "/subscriptions/subid/resourceGroups/mySCOMMIGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", + new UserIdentity()))) + .create(); + } + + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesDeleteSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesDeleteSamples.java new file mode 100644 index 000000000000..58971cebd925 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesDeleteSamples.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +/** Samples for Instances Delete. */ +public final class InstancesDeleteSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Delete.json + */ + /** + * Sample code: Instances_Delete. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesDelete(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().delete("mySCOMMIGroup", "myInstace", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesGetByResourceGroupSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesGetByResourceGroupSamples.java new file mode 100644 index 000000000000..51a82fbe1eb6 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesGetByResourceGroupSamples.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +/** Samples for Instances GetByResourceGroup. */ +public final class InstancesGetByResourceGroupSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Get.json + */ + /** + * Sample code: Instances_Get. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesGet(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().getByResourceGroupWithResponse("myResGroup", "myInstace", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesListByResourceGroupSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesListByResourceGroupSamples.java new file mode 100644 index 000000000000..f4496bad8f13 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesListByResourceGroupSamples.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +/** Samples for Instances ListByResourceGroup. */ +public final class InstancesListByResourceGroupSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instances_ListByResourceGroup.json + */ + /** + * Sample code: Instances_ListByResourceGroup. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesListByResourceGroup(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().listByResourceGroup("mySCOMMIGroup", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesListSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesListSamples.java new file mode 100644 index 000000000000..52ac306f260d --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesListSamples.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +/** Samples for Instances List. */ +public final class InstancesListSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instances_ListBySubscription.json + */ + /** + * Sample code: Instances_ListBySubscription. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesListBySubscription(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesPatchServersSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesPatchServersSamples.java new file mode 100644 index 000000000000..0090241be7ca --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesPatchServersSamples.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +/** Samples for Instances PatchServers. */ +public final class InstancesPatchServersSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instances_PatchServers.json + */ + /** + * Sample code: Instances_PatchServers. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesPatchServers(com.azure.resourcemanager.scom.ScomManager manager) { + manager.instances().patchServers("myResGroup", "myInstace", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesScaleSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesScaleSamples.java new file mode 100644 index 000000000000..3d918962c04b --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesScaleSamples.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +import com.azure.resourcemanager.scom.models.ScalingProperties; + +/** Samples for Instances Scale. */ +public final class InstancesScaleSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Scale.json + */ + /** + * Sample code: Instances_Scale. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesScale(com.azure.resourcemanager.scom.ScomManager manager) { + manager + .instances() + .scale( + "myResGroup", + "myInstace", + new ScalingProperties().withServerCount(3L), + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesUpdateSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesUpdateSamples.java new file mode 100644 index 000000000000..8fd661e9cb5b --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/InstancesUpdateSamples.java @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +import com.azure.resourcemanager.scom.models.MonitoringInstance; +import java.util.HashMap; +import java.util.Map; + +/** Samples for Instances Update. */ +public final class InstancesUpdateSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Instance_Update.json + */ + /** + * Sample code: Instances_Patch. + * + * @param manager Entry point to ScomManager. + */ + public static void instancesPatch(com.azure.resourcemanager.scom.ScomManager manager) { + MonitoringInstance resource = + manager + .instances() + .getByResourceGroupWithResponse("myResGroup", "myInstace", com.azure.core.util.Context.NONE) + .getValue(); + resource + .update() + .withTags(mapOf("additionalProp1", "string", "additionalProp2", "string", "additionalProp3", "string")) + .apply(); + } + + @SuppressWarnings("unchecked") + private static Map mapOf(Object... inputs) { + Map map = new HashMap<>(); + for (int i = 0; i < inputs.length; i += 2) { + String key = (String) inputs[i]; + T value = (T) inputs[i + 1]; + map.put(key, value); + } + return map; + } +} diff --git a/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/OperationsListByResourceGroupSamples.java b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/OperationsListByResourceGroupSamples.java new file mode 100644 index 000000000000..d77f026aa989 --- /dev/null +++ b/sdk/scom/azure-resourcemanager-scom/src/samples/java/com/azure/resourcemanager/scom/generated/OperationsListByResourceGroupSamples.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.scom.generated; + +/** Samples for Operations ListByResourceGroup. */ +public final class OperationsListByResourceGroupSamples { + /* + * x-ms-original-file: specification/scom/resource-manager/Microsoft.SCOM/preview/2022-09-13-preview/examples/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to ScomManager. + */ + public static void operationsList(com.azure.resourcemanager.scom.ScomManager manager) { + manager.operations().listByResourceGroup("myGroup", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/scom/ci.yml b/sdk/scom/ci.yml new file mode 100644 index 000000000000..545f71c51509 --- /dev/null +++ b/sdk/scom/ci.yml @@ -0,0 +1,47 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/scom/ci.yml + - sdk/scom/azure-resourcemanager-scom/ + exclude: + - sdk/scom/pom.xml + - sdk/scom/azure-resourcemanager-scom/pom.xml + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/scom/ci.yml + - sdk/scom/azure-resourcemanager-scom/ + exclude: + - sdk/scom/pom.xml + - sdk/scom/azure-resourcemanager-scom/pom.xml + +parameters: + - name: release_azureresourcemanagerscom + displayName: azure-resourcemanager-scom + type: boolean + default: false + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: scom + EnableBatchRelease: true + Artifacts: + - name: azure-resourcemanager-scom + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerscom + releaseInBatch: ${{ parameters.release_azureresourcemanagerscom }} diff --git a/sdk/scom/pom.xml b/sdk/scom/pom.xml new file mode 100644 index 000000000000..ac9c0087732e --- /dev/null +++ b/sdk/scom/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.azure + azure-scom-service + pom + 1.0.0 + + + azure-resourcemanager-scom + +