diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 5bef20bd1c1f5..25a3e0db28ea1 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -542,6 +542,7 @@ com.azure.resourcemanager:azure-resourcemanager-containerserviceaimanager;1.0.0- com.azure.resourcemanager:azure-resourcemanager-redhatopenshifthcp;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-storagesync;1.0.0;1.1.0-beta.1 com.azure.resourcemanager:azure-resourcemanager-resources-policy;1.0.0-beta.1;1.0.0-beta.1 +com.azure.resourcemanager:azure-resourcemanager-monitor-agents;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;1.1.0-beta.1 com.azure.v2:azure-client-sdk-parent;2.0.0-beta.2;2.0.0-beta.2 diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/CHANGELOG.md b/sdk/monitor/azure-resourcemanager-monitor-agents/CHANGELOG.md new file mode 100644 index 0000000000000..b50c52ab31bc6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 1.0.0-beta.1 (2026-09-03) + +- Azure Resource Manager Monitor Agents client library for Java. This package contains Microsoft Azure SDK for Monitor Agents Management SDK. Monitor Agents Management Client. Package api-version 2026-05-01-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +### Features Added + +- Initial release for the azure-resourcemanager-monitor-agents Java SDK. diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/README.md b/sdk/monitor/azure-resourcemanager-monitor-agents/README.md new file mode 100644 index 0000000000000..b67e54ca709d8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/README.md @@ -0,0 +1,102 @@ +# Azure Resource Manager Monitor Agents client library for Java + +Azure Resource Manager Monitor Agents client library for Java. + +This package contains Microsoft Azure SDK for Monitor Agents Management SDK. Monitor Agents Management Client. Package api-version 2026-05-01-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-monitor-agents;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-monitor-agents + 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 + +Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package. + +Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable. + +Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code: + +```java +AzureProfile profile = new AzureProfile(AzureCloud.AZURE_PUBLIC_CLOUD); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +MonitorAgentsManager manager = MonitorAgentsManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change the `AzureCloud.AZURE_PUBLIC_CLOUD` 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/monitor/azure-resourcemanager-monitor-agents/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://learn.microsoft.com/azure/developer/java/fundamentals/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity +[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials +[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/ diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/SAMPLE.md b/sdk/monitor/azure-resourcemanager-monitor-agents/SAMPLE.md new file mode 100644 index 0000000000000..de21d210ff640 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/SAMPLE.md @@ -0,0 +1,298 @@ +# Code snippets and samples + + +## ObservabilityAgents + +- [CreateOrUpdate](#observabilityagents_createorupdate) +- [Delete](#observabilityagents_delete) +- [GetByResourceGroup](#observabilityagents_getbyresourcegroup) +- [List](#observabilityagents_list) +- [ListByResourceGroup](#observabilityagents_listbyresourcegroup) +- [Update](#observabilityagents_update) + +## Operations + +- [List](#operations_list) +### ObservabilityAgents_CreateOrUpdate + +```java +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ObservabilityAgents CreateOrUpdate. + */ +public final class ObservabilityAgentsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_CreateOrUpdate.json + */ + /** + * Sample code: ObservabilityAgents_CreateOrUpdate. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsCreateOrUpdate(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .define("myObservabilityAgent") + .withRegion("eastus") + .withExistingResourceGroup("myResourceGroup") + .withTags(mapOf("env", "dev")) + .withProperties(new ObservabilityAgentProperties().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace") + .withEnabled(true) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.AUTO) + .withInstructions("use includeAlertsFromGlobalRules"), + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.AUTO) + .withInstructions("focus on recent issues")))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity", + new UserAssignedIdentity()))) + .create(); + } + + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_CreateOrUpdate_MinimumSet.json + */ + /** + * Sample code: ObservabilityAgents_CreateOrUpdate_MinimumSet. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void observabilityAgentsCreateOrUpdateMinimumSet( + com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .define("myObservabilityAgent") + .withRegion("eastus") + .withExistingResourceGroup("myResourceGroup") + .withProperties(new ObservabilityAgentProperties().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity", + new UserAssignedIdentity()))) + .create(); + } + + // Use "Map.of" if available + @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; + } +} +``` + +### ObservabilityAgents_Delete + +```java +/** + * Samples for ObservabilityAgents Delete. + */ +public final class ObservabilityAgentsDeleteSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Delete.json + */ + /** + * Sample code: ObservabilityAgents_Delete. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsDelete(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .deleteByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", + com.azure.core.util.Context.NONE); + } +} +``` + +### ObservabilityAgents_GetByResourceGroup + +```java +/** + * Samples for ObservabilityAgents GetByResourceGroup. + */ +public final class ObservabilityAgentsGetByResourceGroupSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Get.json + */ + /** + * Sample code: ObservabilityAgents_Get. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void observabilityAgentsGet(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .getByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", + com.azure.core.util.Context.NONE); + } +} +``` + +### ObservabilityAgents_List + +```java +/** + * Samples for ObservabilityAgents List. + */ +public final class ObservabilityAgentsListSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_ListBySubscription.json + */ + /** + * Sample code: ObservabilityAgents_ListBySubscription. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsListBySubscription(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents().list(com.azure.core.util.Context.NONE); + } +} +``` + +### ObservabilityAgents_ListByResourceGroup + +```java +/** + * Samples for ObservabilityAgents ListByResourceGroup. + */ +public final class ObservabilityAgentsListByResourceGroupSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_ListByResourceGroup.json + */ + /** + * Sample code: ObservabilityAgents_ListByResourceGroup. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsListByResourceGroup(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents().listByResourceGroup("myResourceGroup", com.azure.core.util.Context.NONE); + } +} +``` + +### ObservabilityAgents_Update + +```java +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPropertiesUpdate; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ObservabilityAgents Update. + */ +public final class ObservabilityAgentsUpdateSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Update_MinimumSet.json + */ + /** + * Sample code: ObservabilityAgents_Update_MinimumSet. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsUpdateMinimumSet(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + ObservabilityAgentResource resource = manager.observabilityAgents() + .getByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withProperties(new ObservabilityAgentPropertiesUpdate().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace")) + .apply(); + } + + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Update.json + */ + /** + * Sample code: ObservabilityAgents_Update. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsUpdate(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + ObservabilityAgentResource resource = manager.observabilityAgents() + .getByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("env", "prod")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity", + new UserAssignedIdentity()))) + .withProperties(new ObservabilityAgentPropertiesUpdate().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace") + .withEnabled(false) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.MANUAL) + .withInstructions("Focus on storage and networking issues only."), + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.AUTO) + .withInstructions("Focus on recent network issues.")))) + .apply(); + } + + // Use "Map.of" if available + @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_List + +```java +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2026-05-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void operationsList(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} +``` + diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/pom.xml b/sdk/monitor/azure-resourcemanager-monitor-agents/pom.xml new file mode 100644 index 0000000000000..efc0384c6c35e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-monitor-agents + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Monitor Agents Management + This package contains Microsoft Azure SDK for Monitor Agents Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Monitor Agents Management Client. Package api-version 2026-05-01-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 + true + + + + com.azure + azure-core + 1.59.1 + + + com.azure + azure-core-management + 1.19.7 + + + com.azure + azure-core-test + 1.27.0-beta.18 + test + + + com.azure + azure-identity + 1.18.5 + test + + + diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/MonitorAgentsManager.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/MonitorAgentsManager.java new file mode 100644 index 0000000000000..6b67cd09d74b8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/MonitorAgentsManager.java @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents; + +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.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryOptions; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.CoreUtils; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.monitor.agents.fluent.MonitorAgentsManagementClient; +import com.azure.resourcemanager.monitor.agents.implementation.MonitorAgentsManagementClientBuilder; +import com.azure.resourcemanager.monitor.agents.implementation.ObservabilityAgentsImpl; +import com.azure.resourcemanager.monitor.agents.implementation.OperationsImpl; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgents; +import com.azure.resourcemanager.monitor.agents.models.Operations; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * Entry point to MonitorAgentsManager. + * Monitor Agents Management Client. + */ +public final class MonitorAgentsManager { + private Operations operations; + + private ObservabilityAgents observabilityAgents; + + private final MonitorAgentsManagementClient clientObject; + + private MonitorAgentsManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = new MonitorAgentsManagementClientBuilder().pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Monitor Agents service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Monitor Agents service API instance. + */ + public static MonitorAgentsManager 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 Monitor Agents service API entry point. + * + * @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential. + * @param profile the Azure profile for client. + * @return the Monitor Agents service API instance. + */ + public static MonitorAgentsManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return new MonitorAgentsManager(httpPipeline, profile, null); + } + + /** + * Gets a Configurable instance that can be used to create MonitorAgentsManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new MonitorAgentsManager.Configurable(); + } + + /** + * The Configurable allowing configurations to be set. + */ + public static final class Configurable { + private static final ClientLogger LOGGER = new ClientLogger(Configurable.class); + private static final String SDK_VERSION = "version"; + private static final Map PROPERTIES + = CoreUtils.getProperties("azure-resourcemanager-monitor-agents.properties"); + + 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 Monitor Agents service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Monitor Agents service API instance. + */ + public MonitorAgentsManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion"); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder.append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.monitor.agents") + .append("/") + .append(clientVersion); + 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 BearerTokenAuthenticationPolicy(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 MonitorAgentsManager(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 ObservabilityAgents. It manages ObservabilityAgentResource. + * + * @return Resource collection API of ObservabilityAgents. + */ + public ObservabilityAgents observabilityAgents() { + if (this.observabilityAgents == null) { + this.observabilityAgents = new ObservabilityAgentsImpl(clientObject.getObservabilityAgents(), this); + } + return observabilityAgents; + } + + /** + * Gets wrapped service client MonitorAgentsManagementClient providing direct access to the underlying + * auto-generated API implementation, based on Azure REST API. + * + * @return Wrapped service client MonitorAgentsManagementClient. + */ + public MonitorAgentsManagementClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/MonitorAgentsManagementClient.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/MonitorAgentsManagementClient.java new file mode 100644 index 0000000000000..d87f2b2e9a633 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/MonitorAgentsManagementClient.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** + * The interface for MonitorAgentsManagementClient class. + */ +public interface MonitorAgentsManagementClient { + /** + * Gets Service host. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * 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 ObservabilityAgentsClient object to access its operations. + * + * @return the ObservabilityAgentsClient object. + */ + ObservabilityAgentsClient getObservabilityAgents(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/ObservabilityAgentsClient.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/ObservabilityAgentsClient.java new file mode 100644 index 0000000000000..2d07eef00421e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/ObservabilityAgentsClient.java @@ -0,0 +1,185 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPatch; + +/** + * An instance of this class provides access to all the operations defined in ObservabilityAgentsClient. + */ +public interface ObservabilityAgentsClient { + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getByResourceGroupWithResponse(String resourceGroupName, + String observabilityAgentName, Context context); + + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ObservabilityAgentResourceInner getByResourceGroup(String resourceGroupName, String observabilityAgentName); + + /** + * Creates or updates an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param resource Properties that need to be specified to create or update an observability agent. + * @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 an observability agent resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response createOrUpdateWithResponse(String resourceGroupName, + String observabilityAgentName, ObservabilityAgentResourceInner resource, Context context); + + /** + * Creates or updates an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param resource Properties that need to be specified to create or update an observability agent. + * @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 an observability agent resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ObservabilityAgentResourceInner createOrUpdate(String resourceGroupName, String observabilityAgentName, + ObservabilityAgentResourceInner resource); + + /** + * Updates part of an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param properties The resource properties to be updated. + * @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 an observability agent resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response updateWithResponse(String resourceGroupName, + String observabilityAgentName, ObservabilityAgentPatch properties, Context context); + + /** + * Updates part of an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param properties The resource properties to be updated. + * @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 an observability agent resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ObservabilityAgentResourceInner update(String resourceGroupName, String observabilityAgentName, + ObservabilityAgentPatch properties); + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response deleteWithResponse(String resourceGroupName, String observabilityAgentName, Context context); + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + void delete(String resourceGroupName, String observabilityAgentName); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/OperationsClient.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/OperationsClient.java new file mode 100644 index 0000000000000..72affedabc535 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/OperationsClient.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.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.monitor.agents.fluent.models.OperationInner; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public interface OperationsClient { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/ObservabilityAgentResourceInner.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/ObservabilityAgentResourceInner.java new file mode 100644 index 0000000000000..d8a11a858ac7b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/ObservabilityAgentResourceInner.java @@ -0,0 +1,212 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.management.Resource; +import com.azure.core.management.SystemData; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties; +import java.io.IOException; +import java.util.Map; + +/** + * An observability agent resource. + */ +@Fluent +public final class ObservabilityAgentResourceInner extends Resource { + /* + * Resource properties + */ + private ObservabilityAgentProperties properties; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Azure Resource Manager metadata containing createdBy and modifiedBy information. + */ + private SystemData systemData; + + /* + * The type of the resource. + */ + private String type; + + /* + * The name of the resource. + */ + private String name; + + /* + * Fully qualified resource Id for the resource. + */ + private String id; + + /** + * Creates an instance of ObservabilityAgentResourceInner class. + */ + public ObservabilityAgentResourceInner() { + } + + /** + * Get the properties property: Resource properties. + * + * @return the properties value. + */ + public ObservabilityAgentProperties properties() { + return this.properties; + } + + /** + * Set the properties property: Resource properties. + * + * @param properties the properties value to set. + * @return the ObservabilityAgentResourceInner object itself. + */ + public ObservabilityAgentResourceInner withProperties(ObservabilityAgentProperties properties) { + this.properties = properties; + return this; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the ObservabilityAgentResourceInner object itself. + */ + public ObservabilityAgentResourceInner withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + public SystemData systemData() { + return this.systemData; + } + + /** + * Get the type property: The type of the resource. + * + * @return the type value. + */ + @Override + public String type() { + return this.type; + } + + /** + * Get the name property: The name of the resource. + * + * @return the name value. + */ + @Override + public String name() { + return this.name; + } + + /** + * Get the id property: Fully qualified resource Id for the resource. + * + * @return the id value. + */ + @Override + public String id() { + return this.id; + } + + /** + * {@inheritDoc} + */ + @Override + public ObservabilityAgentResourceInner withLocation(String location) { + super.withLocation(location); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public ObservabilityAgentResourceInner withTags(Map tags) { + super.withTags(tags); + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("location", location()); + jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("properties", this.properties); + jsonWriter.writeJsonField("identity", this.identity); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ObservabilityAgentResourceInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ObservabilityAgentResourceInner if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ObservabilityAgentResourceInner. + */ + public static ObservabilityAgentResourceInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ObservabilityAgentResourceInner deserializedObservabilityAgentResourceInner + = new ObservabilityAgentResourceInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + deserializedObservabilityAgentResourceInner.id = reader.getString(); + } else if ("name".equals(fieldName)) { + deserializedObservabilityAgentResourceInner.name = reader.getString(); + } else if ("type".equals(fieldName)) { + deserializedObservabilityAgentResourceInner.type = reader.getString(); + } else if ("location".equals(fieldName)) { + deserializedObservabilityAgentResourceInner.withLocation(reader.getString()); + } else if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedObservabilityAgentResourceInner.withTags(tags); + } else if ("properties".equals(fieldName)) { + deserializedObservabilityAgentResourceInner.properties + = ObservabilityAgentProperties.fromJson(reader); + } else if ("identity".equals(fieldName)) { + deserializedObservabilityAgentResourceInner.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("systemData".equals(fieldName)) { + deserializedObservabilityAgentResourceInner.systemData = SystemData.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedObservabilityAgentResourceInner; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/OperationInner.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/OperationInner.java new file mode 100644 index 0000000000000..22088b6d3271f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/OperationInner.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.fluent.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.agents.models.ActionType; +import com.azure.resourcemanager.monitor.agents.models.OperationDisplay; +import com.azure.resourcemanager.monitor.agents.models.Origin; +import java.io.IOException; + +/** + * REST API Operation + * + * Details of a REST API operation, returned from the Resource Provider Operations API. + */ +@Immutable +public final class OperationInner implements JsonSerializable { + /* + * The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action" + */ + private String name; + + /* + * Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + * Resource Manager/control-plane operations. + */ + private Boolean isDataAction; + + /* + * Localized display information for this particular operation. + */ + private OperationDisplay display; + + /* + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + * value is "user,system" + */ + private Origin origin; + + /* + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ + private ActionType actionType; + + /** + * Creates an instance of OperationInner class. + */ + private OperationInner() { + } + + /** + * Get the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Get the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + public Boolean isDataAction() { + return this.isDataAction; + } + + /** + * Get the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Get the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + public Origin origin() { + return this.origin; + } + + /** + * Get the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + public ActionType actionType() { + return this.actionType; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("display", this.display); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationInner from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationInner if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationInner. + */ + public static OperationInner fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationInner deserializedOperationInner = new OperationInner(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedOperationInner.name = reader.getString(); + } else if ("isDataAction".equals(fieldName)) { + deserializedOperationInner.isDataAction = reader.getNullable(JsonReader::getBoolean); + } else if ("display".equals(fieldName)) { + deserializedOperationInner.display = OperationDisplay.fromJson(reader); + } else if ("origin".equals(fieldName)) { + deserializedOperationInner.origin = Origin.fromString(reader.getString()); + } else if ("actionType".equals(fieldName)) { + deserializedOperationInner.actionType = ActionType.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationInner; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/package-info.java new file mode 100644 index 0000000000000..9a8034d36bc14 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/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) TypeSpec Code Generator. + +/** + * Package containing the inner data models for MonitorAgents. + * Monitor Agents Management Client. + */ +package com.azure.resourcemanager.monitor.agents.fluent.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/fluent/package-info.java new file mode 100644 index 0000000000000..d598e7ffcf040 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/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) TypeSpec Code Generator. + +/** + * Package containing the service clients for MonitorAgents. + * Monitor Agents Management Client. + */ +package com.azure.resourcemanager.monitor.agents.fluent; diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientBuilder.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientBuilder.java new file mode 100644 index 0000000000000..e4c433b51455d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientBuilder.java @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.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 MonitorAgentsManagementClientImpl type. + */ +@ServiceClientBuilder(serviceClients = { MonitorAgentsManagementClientImpl.class }) +public final class MonitorAgentsManagementClientBuilder { + /* + * Service host + */ + private String endpoint; + + /** + * Sets Service host. + * + * @param endpoint the endpoint value. + * @return the MonitorAgentsManagementClientBuilder. + */ + public MonitorAgentsManagementClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The ID of the target subscription. The value must be an UUID. + */ + private String subscriptionId; + + /** + * Sets The ID of the target subscription. The value must be an UUID. + * + * @param subscriptionId the subscriptionId value. + * @return the MonitorAgentsManagementClientBuilder. + */ + public MonitorAgentsManagementClientBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the MonitorAgentsManagementClientBuilder. + */ + public MonitorAgentsManagementClientBuilder 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 MonitorAgentsManagementClientBuilder. + */ + public MonitorAgentsManagementClientBuilder 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 MonitorAgentsManagementClientBuilder. + */ + public MonitorAgentsManagementClientBuilder 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 MonitorAgentsManagementClientBuilder. + */ + public MonitorAgentsManagementClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of MonitorAgentsManagementClientImpl with the provided parameters. + * + * @return an instance of MonitorAgentsManagementClientImpl. + */ + public MonitorAgentsManagementClientImpl 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(); + MonitorAgentsManagementClientImpl client = new MonitorAgentsManagementClientImpl(localPipeline, + localSerializerAdapter, localDefaultPollInterval, localEnvironment, localEndpoint, this.subscriptionId); + return client; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientImpl.java new file mode 100644 index 0000000000000..ad99cadaae3e1 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientImpl.java @@ -0,0 +1,324 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaderName; +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.management.polling.SyncPollerFactory; +import com.azure.core.util.BinaryData; +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.polling.SyncPoller; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.monitor.agents.fluent.MonitorAgentsManagementClient; +import com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient; +import com.azure.resourcemanager.monitor.agents.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 MonitorAgentsManagementClientImpl type. + */ +@ServiceClient(builder = MonitorAgentsManagementClientBuilder.class) +public final class MonitorAgentsManagementClientImpl implements MonitorAgentsManagementClient { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Version parameter. + */ + private final String apiVersion; + + /** + * Gets Version parameter. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** + * The ID of the target subscription. The value must be an UUID. + */ + private final String subscriptionId; + + /** + * Gets The ID of the target subscription. The value must be an UUID. + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * 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 ObservabilityAgentsClient object to access its operations. + */ + private final ObservabilityAgentsClient observabilityAgents; + + /** + * Gets the ObservabilityAgentsClient object to access its operations. + * + * @return the ObservabilityAgentsClient object. + */ + public ObservabilityAgentsClient getObservabilityAgents() { + return this.observabilityAgents; + } + + /** + * Initializes an instance of MonitorAgentsManagementClient 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 endpoint Service host. + * @param subscriptionId The ID of the target subscription. The value must be an UUID. + */ + MonitorAgentsManagementClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + Duration defaultPollInterval, AzureEnvironment environment, String endpoint, String subscriptionId) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.subscriptionId = subscriptionId; + this.apiVersion = "2026-05-01-preview"; + this.operations = new OperationsClientImpl(this); + this.observabilityAgents = new ObservabilityAgentsClientImpl(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 long running operation result. + * + * @param activationResponse the response of activation operation. + * @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 SyncPoller for poll result and final result. + */ + public SyncPoller, U> getLroResult(Response activationResponse, + Type pollResultType, Type finalResultType, Context context) { + return SyncPollerFactory.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 ? new byte[0] : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(HttpHeaderName.fromString(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(MonitorAgentsManagementClientImpl.class); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentResourceImpl.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentResourceImpl.java new file mode 100644 index 0000000000000..0cf98aea9ed5e --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentResourceImpl.java @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.implementation; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPatch; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPropertiesUpdate; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import java.util.Collections; +import java.util.Map; + +public final class ObservabilityAgentResourceImpl + implements ObservabilityAgentResource, ObservabilityAgentResource.Definition, ObservabilityAgentResource.Update { + private ObservabilityAgentResourceInner innerObject; + + private final com.azure.resourcemanager.monitor.agents.MonitorAgentsManager 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 ObservabilityAgentProperties properties() { + return this.innerModel().properties(); + } + + public ManagedServiceIdentity identity() { + return this.innerModel().identity(); + } + + public SystemData systemData() { + return this.innerModel().systemData(); + } + + public Region region() { + return Region.fromName(this.regionName()); + } + + public String regionName() { + return this.location(); + } + + public String resourceGroupName() { + return resourceGroupName; + } + + public ObservabilityAgentResourceInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager() { + return this.serviceManager; + } + + private String resourceGroupName; + + private String observabilityAgentName; + + private ObservabilityAgentPatch updateProperties; + + public ObservabilityAgentResourceImpl withExistingResourceGroup(String resourceGroupName) { + this.resourceGroupName = resourceGroupName; + return this; + } + + public ObservabilityAgentResource create() { + this.innerObject = serviceManager.serviceClient() + .getObservabilityAgents() + .createOrUpdateWithResponse(resourceGroupName, observabilityAgentName, this.innerModel(), Context.NONE) + .getValue(); + return this; + } + + public ObservabilityAgentResource create(Context context) { + this.innerObject = serviceManager.serviceClient() + .getObservabilityAgents() + .createOrUpdateWithResponse(resourceGroupName, observabilityAgentName, this.innerModel(), context) + .getValue(); + return this; + } + + ObservabilityAgentResourceImpl(String name, + com.azure.resourcemanager.monitor.agents.MonitorAgentsManager serviceManager) { + this.innerObject = new ObservabilityAgentResourceInner(); + this.serviceManager = serviceManager; + this.observabilityAgentName = name; + } + + public ObservabilityAgentResourceImpl update() { + this.updateProperties = new ObservabilityAgentPatch(); + return this; + } + + public ObservabilityAgentResource apply() { + this.innerObject = serviceManager.serviceClient() + .getObservabilityAgents() + .updateWithResponse(resourceGroupName, observabilityAgentName, updateProperties, Context.NONE) + .getValue(); + return this; + } + + public ObservabilityAgentResource apply(Context context) { + this.innerObject = serviceManager.serviceClient() + .getObservabilityAgents() + .updateWithResponse(resourceGroupName, observabilityAgentName, updateProperties, context) + .getValue(); + return this; + } + + ObservabilityAgentResourceImpl(ObservabilityAgentResourceInner innerObject, + com.azure.resourcemanager.monitor.agents.MonitorAgentsManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + this.resourceGroupName = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "resourceGroups"); + this.observabilityAgentName + = ResourceManagerUtils.getValueFromIdByName(innerObject.id(), "observabilityAgents"); + } + + public ObservabilityAgentResource refresh() { + this.innerObject = serviceManager.serviceClient() + .getObservabilityAgents() + .getByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, Context.NONE) + .getValue(); + return this; + } + + public ObservabilityAgentResource refresh(Context context) { + this.innerObject = serviceManager.serviceClient() + .getObservabilityAgents() + .getByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, context) + .getValue(); + return this; + } + + public ObservabilityAgentResourceImpl withRegion(Region location) { + this.innerModel().withLocation(location.toString()); + return this; + } + + public ObservabilityAgentResourceImpl withRegion(String location) { + this.innerModel().withLocation(location); + return this; + } + + public ObservabilityAgentResourceImpl withTags(Map tags) { + if (isInCreateMode()) { + this.innerModel().withTags(tags); + return this; + } else { + this.updateProperties.withTags(tags); + return this; + } + } + + public ObservabilityAgentResourceImpl withProperties(ObservabilityAgentProperties properties) { + this.innerModel().withProperties(properties); + return this; + } + + public ObservabilityAgentResourceImpl withIdentity(ManagedServiceIdentity identity) { + if (isInCreateMode()) { + this.innerModel().withIdentity(identity); + return this; + } else { + this.updateProperties.withIdentity(identity); + return this; + } + } + + public ObservabilityAgentResourceImpl withProperties(ObservabilityAgentPropertiesUpdate properties) { + this.updateProperties.withProperties(properties); + return this; + } + + private boolean isInCreateMode() { + return this.innerModel() == null || this.innerModel().id() == null; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsClientImpl.java new file mode 100644 index 0000000000000..b9468bb7af3cc --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsClientImpl.java @@ -0,0 +1,833 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.Delete; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.Get; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Patch; +import com.azure.core.annotation.PathParam; +import com.azure.core.annotation.Put; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient; +import com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner; +import com.azure.resourcemanager.monitor.agents.implementation.models.ObservabilityAgentResourceListResult; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPatch; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in ObservabilityAgentsClient. + */ +public final class ObservabilityAgentsClientImpl implements ObservabilityAgentsClient { + /** + * The proxy service used to perform REST calls. + */ + private final ObservabilityAgentsService service; + + /** + * The service client containing this operation class. + */ + private final MonitorAgentsManagementClientImpl client; + + /** + * Initializes an instance of ObservabilityAgentsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ObservabilityAgentsClientImpl(MonitorAgentsManagementClientImpl client) { + this.service = RestProxy.create(ObservabilityAgentsService.class, client.getHttpPipeline(), + client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MonitorAgentsManagementClientObservabilityAgents to be used by the + * proxy service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MonitorAgentsManagementClientObservabilityAgents") + public interface ObservabilityAgentsService { + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> getByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response getByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, @HeaderParam("Accept") String accept, + Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> createOrUpdate(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ObservabilityAgentResourceInner resource, Context context); + + @Put("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200, 201 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response createOrUpdateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ObservabilityAgentResourceInner resource, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> update(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ObservabilityAgentPatch properties, Context context); + + @Patch("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response updateSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") ObservabilityAgentPatch properties, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> delete(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, Context context); + + @Headers({ "Accept: application/json;q=0.9", "Content-Type: application/json" }) + @Delete("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents/{observabilityAgentName}") + @ExpectedResponses({ 200, 204 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response deleteSync(@HostParam("endpoint") String endpoint, @QueryParam("api-version") String apiVersion, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @PathParam("observabilityAgentName") String observabilityAgentName, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listByResourceGroup(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Monitor/observabilityAgents") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByResourceGroupSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, @HeaderParam("Accept") String accept, + Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/observabilityAgents") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/subscriptions/{subscriptionId}/providers/Microsoft.Monitor/observabilityAgents") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @PathParam("subscriptionId") String subscriptionId, + @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("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listByResourceGroupNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") 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("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listBySubscriptionNextSync( + @PathParam(value = "nextLink", encoded = true) String nextLink, @HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, Context context); + } + + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + getByResourceGroupWithResponseAsync(String resourceGroupName, String observabilityAgentName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, accept, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getByResourceGroupAsync(String resourceGroupName, + String observabilityAgentName) { + return getByResourceGroupWithResponseAsync(resourceGroupName, observabilityAgentName) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getByResourceGroupWithResponse(String resourceGroupName, + String observabilityAgentName, Context context) { + final String accept = "application/json"; + return service.getByResourceGroupSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, accept, context); + } + + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ObservabilityAgentResourceInner getByResourceGroup(String resourceGroupName, String observabilityAgentName) { + return getByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, Context.NONE).getValue(); + } + + /** + * Creates or updates an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param resource Properties that need to be specified to create or update an observability agent. + * @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 an observability agent resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> createOrUpdateWithResponseAsync(String resourceGroupName, + String observabilityAgentName, ObservabilityAgentResourceInner resource) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.createOrUpdate(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, contentType, accept, + resource, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Creates or updates an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param resource Properties that need to be specified to create or update an observability agent. + * @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 an observability agent resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono createOrUpdateAsync(String resourceGroupName, + String observabilityAgentName, ObservabilityAgentResourceInner resource) { + return createOrUpdateWithResponseAsync(resourceGroupName, observabilityAgentName, resource) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Creates or updates an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param resource Properties that need to be specified to create or update an observability agent. + * @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 an observability agent resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response createOrUpdateWithResponse(String resourceGroupName, + String observabilityAgentName, ObservabilityAgentResourceInner resource, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createOrUpdateSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, contentType, accept, resource, + context); + } + + /** + * Creates or updates an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param resource Properties that need to be specified to create or update an observability agent. + * @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 an observability agent resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ObservabilityAgentResourceInner createOrUpdate(String resourceGroupName, String observabilityAgentName, + ObservabilityAgentResourceInner resource) { + return createOrUpdateWithResponse(resourceGroupName, observabilityAgentName, resource, Context.NONE).getValue(); + } + + /** + * Updates part of an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param properties The resource properties to be updated. + * @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 an observability agent resource along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> updateWithResponseAsync(String resourceGroupName, + String observabilityAgentName, ObservabilityAgentPatch properties) { + final String contentType = "application/json"; + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.update(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, contentType, accept, + properties, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Updates part of an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param properties The resource properties to be updated. + * @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 an observability agent resource on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono updateAsync(String resourceGroupName, String observabilityAgentName, + ObservabilityAgentPatch properties) { + return updateWithResponseAsync(resourceGroupName, observabilityAgentName, properties) + .flatMap(res -> Mono.justOrEmpty(res.getValue())); + } + + /** + * Updates part of an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param properties The resource properties to be updated. + * @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 an observability agent resource along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response updateWithResponse(String resourceGroupName, + String observabilityAgentName, ObservabilityAgentPatch properties, Context context) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.updateSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, contentType, accept, properties, + context); + } + + /** + * Updates part of an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param properties The resource properties to be updated. + * @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 an observability agent resource. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ObservabilityAgentResourceInner update(String resourceGroupName, String observabilityAgentName, + ObservabilityAgentPatch properties) { + return updateWithResponse(resourceGroupName, observabilityAgentName, properties, Context.NONE).getValue(); + } + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> deleteWithResponseAsync(String resourceGroupName, String observabilityAgentName) { + return FluxUtil + .withContext(context -> service.delete(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 {@link Mono} that completes when a successful response is received. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono deleteAsync(String resourceGroupName, String observabilityAgentName) { + return deleteWithResponseAsync(resourceGroupName, observabilityAgentName).flatMap(ignored -> Mono.empty()); + } + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response deleteWithResponse(String resourceGroupName, String observabilityAgentName, Context context) { + return service.deleteSync(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, observabilityAgentName, context); + } + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public void delete(String resourceGroupName, String observabilityAgentName) { + deleteWithResponse(resourceGroupName, observabilityAgentName, Context.NONE); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByResourceGroupSinglePageAsync(String resourceGroupName) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.listByResourceGroup(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), resourceGroupName, accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listByResourceGroupAsync(String resourceGroupName) { + return new PagedFlux<>(() -> listByResourceGroupSinglePageAsync(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePageAsync(nextLink)); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupSinglePage(String resourceGroupName) { + final String accept = "application/json"; + Response res = service.listByResourceGroupSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupSinglePage(String resourceGroupName, + Context context) { + final String accept = "application/json"; + Response res = service.listByResourceGroupSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), resourceGroupName, accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName) { + return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName), + nextLink -> listByResourceGroupNextSinglePage(nextLink)); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listByResourceGroup(String resourceGroupName, + Context context) { + return new PagedIterable<>(() -> listByResourceGroupSinglePage(resourceGroupName, context), + nextLink -> listByResourceGroupNextSinglePage(nextLink, context)); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), + this.client.getSubscriptionId(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), + res.getStatusCode(), res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), + nextLink -> listBySubscriptionNextSinglePageAsync(nextLink)); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage() { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(Context context) { + final String accept = "application/json"; + Response res = service.listSync(this.client.getEndpoint(), + this.client.getApiVersion(), this.client.getSubscriptionId(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(() -> listSinglePage(), nextLink -> listBySubscriptionNextSinglePage(nextLink)); + } + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(() -> listSinglePage(context), + nextLink -> listBySubscriptionNextSinglePage(nextLink, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ObservabilityAgentResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listByResourceGroupNextSinglePageAsync(String nextLink) { + 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listByResourceGroupNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return 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. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listByResourceGroupNextSinglePage(String nextLink, + Context context) { + final String accept = "application/json"; + Response res + = service.listByResourceGroupNextSync(nextLink, this.client.getEndpoint(), accept, context); + return 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ObservabilityAgentResource list operation along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> + listBySubscriptionNextSinglePageAsync(String nextLink) { + 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listBySubscriptionNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return 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. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response of a ObservabilityAgentResource list operation along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listBySubscriptionNextSinglePage(String nextLink, + Context context) { + final String accept = "application/json"; + Response res + = service.listBySubscriptionNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsImpl.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsImpl.java new file mode 100644 index 0000000000000..368b6f524e447 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsImpl.java @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.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.monitor.agents.fluent.ObservabilityAgentsClient; +import com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgents; + +public final class ObservabilityAgentsImpl implements ObservabilityAgents { + private static final ClientLogger LOGGER = new ClientLogger(ObservabilityAgentsImpl.class); + + private final ObservabilityAgentsClient innerClient; + + private final com.azure.resourcemanager.monitor.agents.MonitorAgentsManager serviceManager; + + public ObservabilityAgentsImpl(ObservabilityAgentsClient innerClient, + com.azure.resourcemanager.monitor.agents.MonitorAgentsManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Response getByResourceGroupWithResponse(String resourceGroupName, + String observabilityAgentName, Context context) { + Response inner + = this.serviceClient().getByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, context); + return new SimpleResponse<>(inner.getRequest(), inner.getStatusCode(), inner.getHeaders(), + new ObservabilityAgentResourceImpl(inner.getValue(), this.manager())); + } + + public ObservabilityAgentResource getByResourceGroup(String resourceGroupName, String observabilityAgentName) { + ObservabilityAgentResourceInner inner + = this.serviceClient().getByResourceGroup(resourceGroupName, observabilityAgentName); + if (inner != null) { + return new ObservabilityAgentResourceImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response deleteByResourceGroupWithResponse(String resourceGroupName, String observabilityAgentName, + Context context) { + return this.serviceClient().deleteWithResponse(resourceGroupName, observabilityAgentName, context); + } + + public void deleteByResourceGroup(String resourceGroupName, String observabilityAgentName) { + this.serviceClient().delete(resourceGroupName, observabilityAgentName); + } + + public PagedIterable listByResourceGroup(String resourceGroupName) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ObservabilityAgentResourceImpl(inner1, this.manager())); + } + + public PagedIterable listByResourceGroup(String resourceGroupName, Context context) { + PagedIterable inner + = this.serviceClient().listByResourceGroup(resourceGroupName, context); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ObservabilityAgentResourceImpl(inner1, this.manager())); + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ObservabilityAgentResourceImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, + inner1 -> new ObservabilityAgentResourceImpl(inner1, this.manager())); + } + + public ObservabilityAgentResource getById(String id) { + String resourceGroupName = ResourceManagerUtils.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 observabilityAgentName = ResourceManagerUtils.getValueFromIdByName(id, "observabilityAgents"); + if (observabilityAgentName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'observabilityAgents'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, Context.NONE).getValue(); + } + + public Response getByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.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 observabilityAgentName = ResourceManagerUtils.getValueFromIdByName(id, "observabilityAgents"); + if (observabilityAgentName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'observabilityAgents'.", id))); + } + return this.getByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, context); + } + + public void deleteById(String id) { + String resourceGroupName = ResourceManagerUtils.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 observabilityAgentName = ResourceManagerUtils.getValueFromIdByName(id, "observabilityAgents"); + if (observabilityAgentName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'observabilityAgents'.", id))); + } + this.deleteByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, Context.NONE); + } + + public Response deleteByIdWithResponse(String id, Context context) { + String resourceGroupName = ResourceManagerUtils.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 observabilityAgentName = ResourceManagerUtils.getValueFromIdByName(id, "observabilityAgents"); + if (observabilityAgentName == null) { + throw LOGGER.logExceptionAsError(new IllegalArgumentException( + String.format("The resource ID '%s' is not valid. Missing path segment 'observabilityAgents'.", id))); + } + return this.deleteByResourceGroupWithResponse(resourceGroupName, observabilityAgentName, context); + } + + private ObservabilityAgentsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager() { + return this.serviceManager; + } + + public ObservabilityAgentResourceImpl define(String name) { + return new ObservabilityAgentResourceImpl(name, this.manager()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationImpl.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationImpl.java new file mode 100644 index 0000000000000..d186200e133d9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationImpl.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.implementation; + +import com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner; +import com.azure.resourcemanager.monitor.agents.models.ActionType; +import com.azure.resourcemanager.monitor.agents.models.Operation; +import com.azure.resourcemanager.monitor.agents.models.OperationDisplay; +import com.azure.resourcemanager.monitor.agents.models.Origin; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final com.azure.resourcemanager.monitor.agents.MonitorAgentsManager serviceManager; + + OperationImpl(OperationInner innerObject, + com.azure.resourcemanager.monitor.agents.MonitorAgentsManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public Boolean isDataAction() { + return this.innerModel().isDataAction(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public Origin origin() { + return this.innerModel().origin(); + } + + public ActionType actionType() { + return this.innerModel().actionType(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsClientImpl.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsClientImpl.java new file mode 100644 index 0000000000000..a61aa113aeebe --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsClientImpl.java @@ -0,0 +1,242 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.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.monitor.agents.fluent.OperationsClient; +import com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner; +import com.azure.resourcemanager.monitor.agents.implementation.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** + * An instance of this class provides access to all the operations defined in OperationsClient. + */ +public final class OperationsClientImpl implements OperationsClient { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final MonitorAgentsManagementClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(MonitorAgentsManagementClientImpl client) { + this.service + = RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MonitorAgentsManagementClientOperations to be used by the proxy + * service to perform REST calls. + */ + @Host("{endpoint}") + @ServiceInterface(name = "MonitorAgentsManagementClientOperations") + public interface OperationsService { + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Monitor/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("/providers/Microsoft.Monitor/operations") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> listNext(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + + @Headers({ "Content-Type: application/json" }) + @Get("{nextLink}") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(ManagementException.class) + Response listNextSync(@PathParam(value = "nextLink", encoded = true) String nextLink, + @HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, Context context); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map(res -> new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), + res.getHeaders(), res.getValue().value(), res.getValue().nextLink(), null)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink)); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage() { + final String accept = "application/json"; + Response res + = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), accept, Context.NONE); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listSinglePage(Context context) { + final String accept = "application/json"; + Response res + = service.listSync(this.client.getEndpoint(), this.client.getApiVersion(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } + + /** + * List the operations for the provider. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(() -> listSinglePage(), nextLink -> listNextSinglePage(nextLink)); + } + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(() -> listSinglePage(context), nextLink -> listNextSinglePage(nextLink, context)); + } + + /** + * Get the next page of items. + * + * @param nextLink The URL to get the next list of items. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse} on + * successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listNextSinglePageAsync(String nextLink) { + 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. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink) { + final String accept = "application/json"; + Response res + = service.listNextSync(nextLink, this.client.getEndpoint(), accept, Context.NONE); + return 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. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider along with {@link PagedResponse}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private PagedResponse listNextSinglePage(String nextLink, Context context) { + final String accept = "application/json"; + Response res = service.listNextSync(nextLink, this.client.getEndpoint(), accept, context); + return new PagedResponseBase<>(res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), + res.getValue().nextLink(), null); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsImpl.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsImpl.java new file mode 100644 index 0000000000000..f07513b7f644f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsImpl.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.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.monitor.agents.fluent.OperationsClient; +import com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner; +import com.azure.resourcemanager.monitor.agents.models.Operation; +import com.azure.resourcemanager.monitor.agents.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.monitor.agents.MonitorAgentsManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, + com.azure.resourcemanager.monitor.agents.MonitorAgentsManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return ResourceManagerUtils.mapPage(inner, inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ResourceManagerUtils.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ResourceManagerUtils.java new file mode 100644 index 0000000000000..0b7a4cebfcfbc --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ResourceManagerUtils.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.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 ResourceManagerUtils { + private ResourceManagerUtils() { + } + + 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.isEmpty() && 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<>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl<>(pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl<>(pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl<>(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/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/ObservabilityAgentResourceListResult.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/ObservabilityAgentResourceListResult.java new file mode 100644 index 0000000000000..319ff01d4f1f9 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/ObservabilityAgentResourceListResult.java @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner; +import java.io.IOException; +import java.util.List; + +/** + * The response of a ObservabilityAgentResource list operation. + */ +@Immutable +public final class ObservabilityAgentResourceListResult + implements JsonSerializable { + /* + * The ObservabilityAgentResource items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of ObservabilityAgentResourceListResult class. + */ + private ObservabilityAgentResourceListResult() { + } + + /** + * Get the value property: The ObservabilityAgentResource items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ObservabilityAgentResourceListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ObservabilityAgentResourceListResult if the JsonReader was pointing to an instance of it, + * or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ObservabilityAgentResourceListResult. + */ + public static ObservabilityAgentResourceListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ObservabilityAgentResourceListResult deserializedObservabilityAgentResourceListResult + = new ObservabilityAgentResourceListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value + = reader.readArray(reader1 -> ObservabilityAgentResourceInner.fromJson(reader1)); + deserializedObservabilityAgentResourceListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedObservabilityAgentResourceListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedObservabilityAgentResourceListResult; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/OperationListResult.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/OperationListResult.java new file mode 100644 index 0000000000000..b7c9260092cdd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/OperationListResult.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.implementation.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner; +import java.io.IOException; +import java.util.List; + +/** + * A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of + * results. + */ +@Immutable +public final class OperationListResult implements JsonSerializable { + /* + * The Operation items on this page + */ + private List value; + + /* + * The link to the next page of items + */ + private String nextLink; + + /** + * Creates an instance of OperationListResult class. + */ + private OperationListResult() { + } + + /** + * Get the value property: The Operation items on this page. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Get the nextLink property: The link to the next page of items. + * + * @return the nextLink value. + */ + public String nextLink() { + return this.nextLink; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("value", this.value, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeStringField("nextLink", this.nextLink); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationListResult from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationListResult if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OperationListResult. + */ + public static OperationListResult fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationListResult deserializedOperationListResult = new OperationListResult(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + List value = reader.readArray(reader1 -> OperationInner.fromJson(reader1)); + deserializedOperationListResult.value = value; + } else if ("nextLink".equals(fieldName)) { + deserializedOperationListResult.nextLink = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationListResult; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/implementation/package-info.java new file mode 100644 index 0000000000000..7b1c0675bffcd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/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) TypeSpec Code Generator. + +/** + * Package containing the implementations for MonitorAgents. + * Monitor Agents Management Client. + */ +package com.azure.resourcemanager.monitor.agents.implementation; diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ActionType.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ActionType.java new file mode 100644 index 0000000000000..896dbd57f248c --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ActionType.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + */ +public final class ActionType extends ExpandableStringEnum { + /** + * Actions are for internal-only APIs. + */ + public static final ActionType INTERNAL = fromString("Internal"); + + /** + * Creates a new instance of ActionType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ActionType() { + } + + /** + * Creates or finds a ActionType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ActionType. + */ + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * Gets known ActionType values. + * + * @return known ActionType values. + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentity.java new file mode 100644 index 0000000000000..58706cfa47aeb --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentity.java @@ -0,0 +1,154 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Managed service identity (system assigned and/or user assigned identities). + */ +@Fluent +public final class ManagedServiceIdentity implements JsonSerializable { + /* + * The service principal ID of the system assigned identity. This property will only be provided for a system + * assigned identity. + */ + private String principalId; + + /* + * The tenant ID of the system assigned identity. This property will only be provided for a system assigned + * identity. + */ + private String tenantId; + + /* + * The type of managed identity assigned to this resource. + */ + private ManagedServiceIdentityType type; + + /* + * The identities assigned to this resource by the user. + */ + private Map userAssignedIdentities; + + /** + * Creates an instance of ManagedServiceIdentity class. + */ + public ManagedServiceIdentity() { + } + + /** + * Get the principalId property: The service principal ID of the system assigned identity. This property will only + * be provided for a system assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the tenantId property: The tenant ID of the system assigned identity. This property will only be provided for + * a system assigned identity. + * + * @return the tenantId value. + */ + public String tenantId() { + return this.tenantId; + } + + /** + * Get the type property: The type of managed identity assigned to this resource. + * + * @return the type value. + */ + public ManagedServiceIdentityType type() { + return this.type; + } + + /** + * Set the type property: The type of managed identity assigned to this resource. + * + * @param type the type value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withType(ManagedServiceIdentityType type) { + this.type = type; + return this; + } + + /** + * Get the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @return the userAssignedIdentities value. + */ + public Map userAssignedIdentities() { + return this.userAssignedIdentities; + } + + /** + * Set the userAssignedIdentities property: The identities assigned to this resource by the user. + * + * @param userAssignedIdentities the userAssignedIdentities value to set. + * @return the ManagedServiceIdentity object itself. + */ + public ManagedServiceIdentity withUserAssignedIdentities(Map userAssignedIdentities) { + this.userAssignedIdentities = userAssignedIdentities; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeMapField("userAssignedIdentities", this.userAssignedIdentities, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ManagedServiceIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ManagedServiceIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ManagedServiceIdentity. + */ + public static ManagedServiceIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ManagedServiceIdentity deserializedManagedServiceIdentity = new ManagedServiceIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedManagedServiceIdentity.type = ManagedServiceIdentityType.fromString(reader.getString()); + } else if ("principalId".equals(fieldName)) { + deserializedManagedServiceIdentity.principalId = reader.getString(); + } else if ("tenantId".equals(fieldName)) { + deserializedManagedServiceIdentity.tenantId = reader.getString(); + } else if ("userAssignedIdentities".equals(fieldName)) { + Map userAssignedIdentities + = reader.readMap(reader1 -> UserAssignedIdentity.fromJson(reader1)); + deserializedManagedServiceIdentity.userAssignedIdentities = userAssignedIdentities; + } else { + reader.skipChildren(); + } + } + + return deserializedManagedServiceIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentityType.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentityType.java new file mode 100644 index 0000000000000..e536528759342 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentityType.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + */ +public final class ManagedServiceIdentityType extends ExpandableStringEnum { + /** + * No managed identity. + */ + public static final ManagedServiceIdentityType NONE = fromString("None"); + + /** + * System assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED = fromString("SystemAssigned"); + + /** + * User assigned managed identity. + */ + public static final ManagedServiceIdentityType USER_ASSIGNED = fromString("UserAssigned"); + + /** + * System and user assigned managed identity. + */ + public static final ManagedServiceIdentityType SYSTEM_ASSIGNED_USER_ASSIGNED + = fromString("SystemAssigned,UserAssigned"); + + /** + * Creates a new instance of ManagedServiceIdentityType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ManagedServiceIdentityType() { + } + + /** + * Creates or finds a ManagedServiceIdentityType from its string representation. + * + * @param name a name to look for. + * @return the corresponding ManagedServiceIdentityType. + */ + public static ManagedServiceIdentityType fromString(String name) { + return fromString(name, ManagedServiceIdentityType.class); + } + + /** + * Gets known ManagedServiceIdentityType values. + * + * @return known ManagedServiceIdentityType values. + */ + public static Collection values() { + return values(ManagedServiceIdentityType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPatch.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPatch.java new file mode 100644 index 0000000000000..b63d38be3c164 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPatch.java @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * The request body used to update an observability agent resource. + */ +@Fluent +public final class ObservabilityAgentPatch implements JsonSerializable { + /* + * Resource tags. + */ + private Map tags; + + /* + * The managed service identities assigned to this resource. + */ + private ManagedServiceIdentity identity; + + /* + * Updatable resource properties. + */ + private ObservabilityAgentPropertiesUpdate properties; + + /** + * Creates an instance of ObservabilityAgentPatch class. + */ + public ObservabilityAgentPatch() { + } + + /** + * 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 ObservabilityAgentPatch object itself. + */ + public ObservabilityAgentPatch withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + public ManagedServiceIdentity identity() { + return this.identity; + } + + /** + * Set the identity property: The managed service identities assigned to this resource. + * + * @param identity the identity value to set. + * @return the ObservabilityAgentPatch object itself. + */ + public ObservabilityAgentPatch withIdentity(ManagedServiceIdentity identity) { + this.identity = identity; + return this; + } + + /** + * Get the properties property: Updatable resource properties. + * + * @return the properties value. + */ + public ObservabilityAgentPropertiesUpdate properties() { + return this.properties; + } + + /** + * Set the properties property: Updatable resource properties. + * + * @param properties the properties value to set. + * @return the ObservabilityAgentPatch object itself. + */ + public ObservabilityAgentPatch withProperties(ObservabilityAgentPropertiesUpdate properties) { + this.properties = properties; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("tags", this.tags, (writer, element) -> writer.writeString(element)); + jsonWriter.writeJsonField("identity", this.identity); + jsonWriter.writeJsonField("properties", this.properties); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ObservabilityAgentPatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ObservabilityAgentPatch if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the ObservabilityAgentPatch. + */ + public static ObservabilityAgentPatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ObservabilityAgentPatch deserializedObservabilityAgentPatch = new ObservabilityAgentPatch(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("tags".equals(fieldName)) { + Map tags = reader.readMap(reader1 -> reader1.getString()); + deserializedObservabilityAgentPatch.tags = tags; + } else if ("identity".equals(fieldName)) { + deserializedObservabilityAgentPatch.identity = ManagedServiceIdentity.fromJson(reader); + } else if ("properties".equals(fieldName)) { + deserializedObservabilityAgentPatch.properties + = ObservabilityAgentPropertiesUpdate.fromJson(reader); + } else { + reader.skipChildren(); + } + } + + return deserializedObservabilityAgentPatch; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentProperties.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentProperties.java new file mode 100644 index 0000000000000..531b0318195dc --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentProperties.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Properties for an observability agent resource. + */ +@Fluent +public final class ObservabilityAgentProperties implements JsonSerializable { + /* + * The resource provisioning state. + */ + private ResourceProvisioningState provisioningState; + + /* + * Resource ID of the Azure Monitor workspace where this agent stores the issues it produces. + */ + private String monitoringAccountId; + + /* + * Whether the observability agent is enabled. Defaults to true when not specified. + */ + private Boolean enabled; + + /* + * Configuration overrides for agent operations. When omitted, default behavior applies for all operations. + */ + private List operations; + + /** + * Creates an instance of ObservabilityAgentProperties class. + */ + public ObservabilityAgentProperties() { + } + + /** + * Get the provisioningState property: The resource provisioning state. + * + * @return the provisioningState value. + */ + public ResourceProvisioningState provisioningState() { + return this.provisioningState; + } + + /** + * Get the monitoringAccountId property: Resource ID of the Azure Monitor workspace where this agent stores the + * issues it produces. + * + * @return the monitoringAccountId value. + */ + public String monitoringAccountId() { + return this.monitoringAccountId; + } + + /** + * Set the monitoringAccountId property: Resource ID of the Azure Monitor workspace where this agent stores the + * issues it produces. + * + * @param monitoringAccountId the monitoringAccountId value to set. + * @return the ObservabilityAgentProperties object itself. + */ + public ObservabilityAgentProperties withMonitoringAccountId(String monitoringAccountId) { + this.monitoringAccountId = monitoringAccountId; + return this; + } + + /** + * Get the enabled property: Whether the observability agent is enabled. Defaults to true when not specified. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: Whether the observability agent is enabled. Defaults to true when not specified. + * + * @param enabled the enabled value to set. + * @return the ObservabilityAgentProperties object itself. + */ + public ObservabilityAgentProperties withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the operations property: Configuration overrides for agent operations. When omitted, default behavior applies + * for all operations. + * + * @return the operations value. + */ + public List operations() { + return this.operations; + } + + /** + * Set the operations property: Configuration overrides for agent operations. When omitted, default behavior applies + * for all operations. + * + * @param operations the operations value to set. + * @return the ObservabilityAgentProperties object itself. + */ + public ObservabilityAgentProperties withOperations(List operations) { + this.operations = operations; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("monitoringAccountId", this.monitoringAccountId); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeArrayField("operations", this.operations, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ObservabilityAgentProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ObservabilityAgentProperties if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ObservabilityAgentProperties. + */ + public static ObservabilityAgentProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ObservabilityAgentProperties deserializedObservabilityAgentProperties = new ObservabilityAgentProperties(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("monitoringAccountId".equals(fieldName)) { + deserializedObservabilityAgentProperties.monitoringAccountId = reader.getString(); + } else if ("provisioningState".equals(fieldName)) { + deserializedObservabilityAgentProperties.provisioningState + = ResourceProvisioningState.fromString(reader.getString()); + } else if ("enabled".equals(fieldName)) { + deserializedObservabilityAgentProperties.enabled = reader.getNullable(JsonReader::getBoolean); + } else if ("operations".equals(fieldName)) { + List operations = reader.readArray(reader1 -> OperationEntry.fromJson(reader1)); + deserializedObservabilityAgentProperties.operations = operations; + } else { + reader.skipChildren(); + } + } + + return deserializedObservabilityAgentProperties; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPropertiesUpdate.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPropertiesUpdate.java new file mode 100644 index 0000000000000..b68d102ebaf23 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPropertiesUpdate.java @@ -0,0 +1,152 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Updatable properties of an observability agent. + */ +@Fluent +public final class ObservabilityAgentPropertiesUpdate implements JsonSerializable { + /* + * Resource ID of the Azure Monitor workspace where this agent stores the issues it produces. If changed, existing + * issues remain in the previously configured workspace and are not migrated; only newly created issues are written + * to the new workspace. + */ + private String monitoringAccountId; + + /* + * Whether the observability agent is enabled. + */ + private Boolean enabled; + + /* + * Configuration overrides for agent operations. When omitted, default behavior applies for all operations. + */ + private List operations; + + /** + * Creates an instance of ObservabilityAgentPropertiesUpdate class. + */ + public ObservabilityAgentPropertiesUpdate() { + } + + /** + * Get the monitoringAccountId property: Resource ID of the Azure Monitor workspace where this agent stores the + * issues it produces. If changed, existing issues remain in the previously configured workspace and are not + * migrated; only newly created issues are written to the new workspace. + * + * @return the monitoringAccountId value. + */ + public String monitoringAccountId() { + return this.monitoringAccountId; + } + + /** + * Set the monitoringAccountId property: Resource ID of the Azure Monitor workspace where this agent stores the + * issues it produces. If changed, existing issues remain in the previously configured workspace and are not + * migrated; only newly created issues are written to the new workspace. + * + * @param monitoringAccountId the monitoringAccountId value to set. + * @return the ObservabilityAgentPropertiesUpdate object itself. + */ + public ObservabilityAgentPropertiesUpdate withMonitoringAccountId(String monitoringAccountId) { + this.monitoringAccountId = monitoringAccountId; + return this; + } + + /** + * Get the enabled property: Whether the observability agent is enabled. + * + * @return the enabled value. + */ + public Boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled property: Whether the observability agent is enabled. + * + * @param enabled the enabled value to set. + * @return the ObservabilityAgentPropertiesUpdate object itself. + */ + public ObservabilityAgentPropertiesUpdate withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the operations property: Configuration overrides for agent operations. When omitted, default behavior applies + * for all operations. + * + * @return the operations value. + */ + public List operations() { + return this.operations; + } + + /** + * Set the operations property: Configuration overrides for agent operations. When omitted, default behavior applies + * for all operations. + * + * @param operations the operations value to set. + * @return the ObservabilityAgentPropertiesUpdate object itself. + */ + public ObservabilityAgentPropertiesUpdate withOperations(List operations) { + this.operations = operations; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("monitoringAccountId", this.monitoringAccountId); + jsonWriter.writeBooleanField("enabled", this.enabled); + jsonWriter.writeArrayField("operations", this.operations, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ObservabilityAgentPropertiesUpdate from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ObservabilityAgentPropertiesUpdate if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IOException If an error occurs while reading the ObservabilityAgentPropertiesUpdate. + */ + public static ObservabilityAgentPropertiesUpdate fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ObservabilityAgentPropertiesUpdate deserializedObservabilityAgentPropertiesUpdate + = new ObservabilityAgentPropertiesUpdate(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("monitoringAccountId".equals(fieldName)) { + deserializedObservabilityAgentPropertiesUpdate.monitoringAccountId = reader.getString(); + } else if ("enabled".equals(fieldName)) { + deserializedObservabilityAgentPropertiesUpdate.enabled = reader.getNullable(JsonReader::getBoolean); + } else if ("operations".equals(fieldName)) { + List operations = reader.readArray(reader1 -> OperationEntry.fromJson(reader1)); + deserializedObservabilityAgentPropertiesUpdate.operations = operations; + } else { + reader.skipChildren(); + } + } + + return deserializedObservabilityAgentPropertiesUpdate; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentResource.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentResource.java new file mode 100644 index 0000000000000..57b900b5e2056 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentResource.java @@ -0,0 +1,299 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.management.Region; +import com.azure.core.management.SystemData; +import com.azure.core.util.Context; +import com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner; +import java.util.Map; + +/** + * An immutable client-side representation of ObservabilityAgentResource. + */ +public interface ObservabilityAgentResource { + /** + * 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: Resource properties. + * + * @return the properties value. + */ + ObservabilityAgentProperties properties(); + + /** + * Gets the identity property: The managed service identities assigned to this resource. + * + * @return the identity value. + */ + ManagedServiceIdentity identity(); + + /** + * Gets the systemData property: Azure Resource Manager metadata containing createdBy and modifiedBy information. + * + * @return the systemData value. + */ + SystemData systemData(); + + /** + * 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.monitor.agents.fluent.models.ObservabilityAgentResourceInner object. + * + * @return the inner object. + */ + ObservabilityAgentResourceInner innerModel(); + + /** + * The entirety of the ObservabilityAgentResource definition. + */ + interface Definition extends DefinitionStages.Blank, DefinitionStages.WithLocation, + DefinitionStages.WithResourceGroup, DefinitionStages.WithCreate { + } + + /** + * The ObservabilityAgentResource definition stages. + */ + interface DefinitionStages { + /** + * The first stage of the ObservabilityAgentResource definition. + */ + interface Blank extends WithLocation { + } + + /** + * The stage of the ObservabilityAgentResource 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 ObservabilityAgentResource 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 ObservabilityAgentResource 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 { + /** + * Executes the create request. + * + * @return the created resource. + */ + ObservabilityAgentResource create(); + + /** + * Executes the create request. + * + * @param context The context to associate with this operation. + * @return the created resource. + */ + ObservabilityAgentResource create(Context context); + } + + /** + * The stage of the ObservabilityAgentResource 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 ObservabilityAgentResource definition allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: Resource properties. + * + * @param properties Resource properties. + * @return the next definition stage. + */ + WithCreate withProperties(ObservabilityAgentProperties properties); + } + + /** + * The stage of the ObservabilityAgentResource definition allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + WithCreate withIdentity(ManagedServiceIdentity identity); + } + } + + /** + * Begins update for the ObservabilityAgentResource resource. + * + * @return the stage of resource update. + */ + ObservabilityAgentResource.Update update(); + + /** + * The template for ObservabilityAgentResource update. + */ + interface Update extends UpdateStages.WithTags, UpdateStages.WithIdentity, UpdateStages.WithProperties { + /** + * Executes the update request. + * + * @return the updated resource. + */ + ObservabilityAgentResource apply(); + + /** + * Executes the update request. + * + * @param context The context to associate with this operation. + * @return the updated resource. + */ + ObservabilityAgentResource apply(Context context); + } + + /** + * The ObservabilityAgentResource update stages. + */ + interface UpdateStages { + /** + * The stage of the ObservabilityAgentResource update allowing to specify tags. + */ + interface WithTags { + /** + * Specifies the tags property: Resource tags.. + * + * @param tags Resource tags. + * @return the next definition stage. + */ + Update withTags(Map tags); + } + + /** + * The stage of the ObservabilityAgentResource update allowing to specify identity. + */ + interface WithIdentity { + /** + * Specifies the identity property: The managed service identities assigned to this resource.. + * + * @param identity The managed service identities assigned to this resource. + * @return the next definition stage. + */ + Update withIdentity(ManagedServiceIdentity identity); + } + + /** + * The stage of the ObservabilityAgentResource update allowing to specify properties. + */ + interface WithProperties { + /** + * Specifies the properties property: Updatable resource properties.. + * + * @param properties Updatable resource properties. + * @return the next definition stage. + */ + Update withProperties(ObservabilityAgentPropertiesUpdate properties); + } + } + + /** + * Refreshes the resource to sync with Azure. + * + * @return the refreshed resource. + */ + ObservabilityAgentResource refresh(); + + /** + * Refreshes the resource to sync with Azure. + * + * @param context The context to associate with this operation. + * @return the refreshed resource. + */ + ObservabilityAgentResource refresh(Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgents.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgents.java new file mode 100644 index 0000000000000..01ea8040ade7a --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgents.java @@ -0,0 +1,165 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.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 ObservabilityAgents. + */ +public interface ObservabilityAgents { + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource along with {@link Response}. + */ + Response getByResourceGroupWithResponse(String resourceGroupName, + String observabilityAgentName, Context context); + + /** + * Returns the specified observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. 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 an observability agent resource. + */ + ObservabilityAgentResource getByResourceGroup(String resourceGroupName, String observabilityAgentName); + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByResourceGroupWithResponse(String resourceGroupName, String observabilityAgentName, + Context context); + + /** + * Deletes an observability agent. + * + * @param resourceGroupName The name of the resource group. The name is case insensitive. + * @param observabilityAgentName The name of the observability agent resource. The name is case insensitive. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + void deleteByResourceGroup(String resourceGroupName, String observabilityAgentName); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable listByResourceGroup(String resourceGroupName, Context context); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * Lists observability agents in the specified 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 the response of a ObservabilityAgentResource list operation as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); + + /** + * Returns the specified observability agent. + * + * @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 an observability agent resource along with {@link Response}. + */ + ObservabilityAgentResource getById(String id); + + /** + * Returns the specified observability agent. + * + * @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 an observability agent resource along with {@link Response}. + */ + Response getByIdWithResponse(String id, Context context); + + /** + * Deletes an observability agent. + * + * @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); + + /** + * Deletes an observability agent. + * + * @param id the resource ID. + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the {@link Response}. + */ + Response deleteByIdWithResponse(String id, Context context); + + /** + * Begins definition for a new ObservabilityAgentResource resource. + * + * @param name resource name. + * @return the first stage of the new ObservabilityAgentResource definition. + */ + ObservabilityAgentResource.DefinitionStages.Blank define(String name); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Operation.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Operation.java new file mode 100644 index 0000000000000..97f4ecc205abe --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Operation.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner; + +/** + * An immutable client-side representation of Operation. + */ +public interface Operation { + /** + * Gets the name property: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + * "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + * + * @return the name value. + */ + String name(); + + /** + * Gets the isDataAction property: Whether the operation applies to data-plane. This is "true" for data-plane + * operations and "false" for Azure Resource Manager/control-plane operations. + * + * @return the isDataAction value. + */ + Boolean isDataAction(); + + /** + * Gets the display property: Localized display information for this particular operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The intended executor of the operation; as in Resource Based Access Control (RBAC) and + * audit logs UX. Default value is "user,system". + * + * @return the origin value. + */ + Origin origin(); + + /** + * Gets the actionType property: Extensible enum. Indicates the action type. "Internal" refers to actions that are + * for internal only APIs. + * + * @return the actionType value. + */ + ActionType actionType(); + + /** + * Gets the inner com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationDisplay.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationDisplay.java new file mode 100644 index 0000000000000..63c6ab9ffb093 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationDisplay.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Localized display information for an operation. + */ +@Immutable +public final class OperationDisplay implements JsonSerializable { + /* + * The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or + * "Microsoft Compute". + */ + private String provider; + + /* + * The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or + * "Job Schedule Collections". + */ + private String resource; + + /* + * The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + */ + private String operation; + + /* + * The short, localized friendly description of the operation; suitable for tool tips and detailed views. + */ + private String description; + + /** + * Creates an instance of OperationDisplay class. + */ + private OperationDisplay() { + } + + /** + * Get the provider property: The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring + * Insights" or "Microsoft Compute". + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Get the resource property: The localized friendly name of the resource type related to this operation. E.g. + * "Virtual Machines" or "Job Schedule Collections". + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Get the operation property: The concise, localized friendly name for the operation; suitable for dropdowns. E.g. + * "Create or Update Virtual Machine", "Restart Virtual Machine". + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Get the description property: The short, localized friendly description of the operation; suitable for tool tips + * and detailed views. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationDisplay from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationDisplay if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the OperationDisplay. + */ + public static OperationDisplay fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationDisplay deserializedOperationDisplay = new OperationDisplay(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("provider".equals(fieldName)) { + deserializedOperationDisplay.provider = reader.getString(); + } else if ("resource".equals(fieldName)) { + deserializedOperationDisplay.resource = reader.getString(); + } else if ("operation".equals(fieldName)) { + deserializedOperationDisplay.operation = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedOperationDisplay.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationDisplay; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationEntry.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationEntry.java new file mode 100644 index 0000000000000..96ceb1c7544cd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationEntry.java @@ -0,0 +1,142 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.annotation.Fluent; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * Configuration for a specific agent operation. + */ +@Fluent +public final class OperationEntry implements JsonSerializable { + /* + * Type of operation. + */ + private OperationType type; + + /* + * Execution mode for this operation. Defaults to Auto when not specified. + */ + private OperationMode mode; + + /* + * Custom instructions that guide the agent's behavior for this operation. + */ + private String instructions; + + /** + * Creates an instance of OperationEntry class. + */ + public OperationEntry() { + } + + /** + * Get the type property: Type of operation. + * + * @return the type value. + */ + public OperationType type() { + return this.type; + } + + /** + * Set the type property: Type of operation. + * + * @param type the type value to set. + * @return the OperationEntry object itself. + */ + public OperationEntry withType(OperationType type) { + this.type = type; + return this; + } + + /** + * Get the mode property: Execution mode for this operation. Defaults to Auto when not specified. + * + * @return the mode value. + */ + public OperationMode mode() { + return this.mode; + } + + /** + * Set the mode property: Execution mode for this operation. Defaults to Auto when not specified. + * + * @param mode the mode value to set. + * @return the OperationEntry object itself. + */ + public OperationEntry withMode(OperationMode mode) { + this.mode = mode; + return this; + } + + /** + * Get the instructions property: Custom instructions that guide the agent's behavior for this operation. + * + * @return the instructions value. + */ + public String instructions() { + return this.instructions; + } + + /** + * Set the instructions property: Custom instructions that guide the agent's behavior for this operation. + * + * @param instructions the instructions value to set. + * @return the OperationEntry object itself. + */ + public OperationEntry withInstructions(String instructions) { + this.instructions = instructions; + return this; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("type", this.type == null ? null : this.type.toString()); + jsonWriter.writeStringField("mode", this.mode == null ? null : this.mode.toString()); + jsonWriter.writeStringField("instructions", this.instructions); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OperationEntry from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OperationEntry if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the OperationEntry. + */ + public static OperationEntry fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OperationEntry deserializedOperationEntry = new OperationEntry(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("type".equals(fieldName)) { + deserializedOperationEntry.type = OperationType.fromString(reader.getString()); + } else if ("mode".equals(fieldName)) { + deserializedOperationEntry.mode = OperationMode.fromString(reader.getString()); + } else if ("instructions".equals(fieldName)) { + deserializedOperationEntry.instructions = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedOperationEntry; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationMode.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationMode.java new file mode 100644 index 0000000000000..ad8d64c531c40 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationMode.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Execution mode for a specific agent operation. + */ +public final class OperationMode extends ExpandableStringEnum { + /** + * The operation runs autonomously. + */ + public static final OperationMode AUTO = fromString("Auto"); + + /** + * The operation runs only when triggered manually. + */ + public static final OperationMode MANUAL = fromString("Manual"); + + /** + * Creates a new instance of OperationMode value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public OperationMode() { + } + + /** + * Creates or finds a OperationMode from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationMode. + */ + public static OperationMode fromString(String name) { + return fromString(name, OperationMode.class); + } + + /** + * Gets known OperationMode values. + * + * @return known OperationMode values. + */ + public static Collection values() { + return values(OperationMode.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationType.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationType.java new file mode 100644 index 0000000000000..b336434b2007d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationType.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * Type of agent operation. + */ +public final class OperationType extends ExpandableStringEnum { + /** + * Issue creation operation. + */ + public static final OperationType ISSUE_CREATION = fromString("IssueCreation"); + + /** + * Investigation operation. + */ + public static final OperationType INVESTIGATION = fromString("Investigation"); + + /** + * Creates a new instance of OperationType value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public OperationType() { + } + + /** + * Creates or finds a OperationType from its string representation. + * + * @param name a name to look for. + * @return the corresponding OperationType. + */ + public static OperationType fromString(String name) { + return fromString(name, OperationType.class); + } + + /** + * Gets known OperationType values. + * + * @return known OperationType values. + */ + public static Collection values() { + return values(OperationType.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Operations.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Operations.java new file mode 100644 index 0000000000000..6200b08c65aaa --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Operations.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** + * Resource collection API of Operations. + */ +public interface Operations { + /** + * List the operations for the provider. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(); + + /** + * List the operations for the provider. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a list of REST API operations supported by an Azure Resource Provider as paginated response with + * {@link PagedIterable}. + */ + PagedIterable list(Context context); +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Origin.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Origin.java new file mode 100644 index 0000000000000..98d861bc02f6d --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/Origin.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default value + * is "user,system". + */ +public final class Origin extends ExpandableStringEnum { + /** + * Indicates the operation is initiated by a user. + */ + public static final Origin USER = fromString("user"); + + /** + * Indicates the operation is initiated by a system. + */ + public static final Origin SYSTEM = fromString("system"); + + /** + * Indicates the operation is initiated by a user or system. + */ + public static final Origin USER_SYSTEM = fromString("user,system"); + + /** + * Creates a new instance of Origin value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public Origin() { + } + + /** + * Creates or finds a Origin from its string representation. + * + * @param name a name to look for. + * @return the corresponding Origin. + */ + public static Origin fromString(String name) { + return fromString(name, Origin.class); + } + + /** + * Gets known Origin values. + * + * @return known Origin values. + */ + public static Collection values() { + return values(Origin.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ResourceProvisioningState.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ResourceProvisioningState.java new file mode 100644 index 0000000000000..f9c5513d731a5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/ResourceProvisioningState.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.util.ExpandableStringEnum; +import java.util.Collection; + +/** + * The provisioning state of a resource type. + */ +public final class ResourceProvisioningState extends ExpandableStringEnum { + /** + * Resource has been created. + */ + public static final ResourceProvisioningState SUCCEEDED = fromString("Succeeded"); + + /** + * Resource creation failed. + */ + public static final ResourceProvisioningState FAILED = fromString("Failed"); + + /** + * Resource creation was canceled. + */ + public static final ResourceProvisioningState CANCELED = fromString("Canceled"); + + /** + * Creates a new instance of ResourceProvisioningState value. + * + * @deprecated Use the {@link #fromString(String)} factory method. + */ + @Deprecated + public ResourceProvisioningState() { + } + + /** + * Creates or finds a ResourceProvisioningState from its string representation. + * + * @param name a name to look for. + * @return the corresponding ResourceProvisioningState. + */ + public static ResourceProvisioningState fromString(String name) { + return fromString(name, ResourceProvisioningState.class); + } + + /** + * Gets known ResourceProvisioningState values. + * + * @return known ResourceProvisioningState values. + */ + public static Collection values() { + return values(ResourceProvisioningState.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/UserAssignedIdentity.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/UserAssignedIdentity.java new file mode 100644 index 0000000000000..b6406c03021d2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/UserAssignedIdentity.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.models; + +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * User assigned identity properties. + */ +@Immutable +public final class UserAssignedIdentity implements JsonSerializable { + /* + * The principal ID of the assigned identity. + */ + private String principalId; + + /* + * The client ID of the assigned identity. + */ + private String clientId; + + /** + * Creates an instance of UserAssignedIdentity class. + */ + public UserAssignedIdentity() { + } + + /** + * Get the principalId property: The principal ID of the assigned identity. + * + * @return the principalId value. + */ + public String principalId() { + return this.principalId; + } + + /** + * Get the clientId property: The client ID of the assigned identity. + * + * @return the clientId value. + */ + public String clientId() { + return this.clientId; + } + + /** + * {@inheritDoc} + */ + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UserAssignedIdentity from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UserAssignedIdentity if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UserAssignedIdentity. + */ + public static UserAssignedIdentity fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UserAssignedIdentity deserializedUserAssignedIdentity = new UserAssignedIdentity(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("principalId".equals(fieldName)) { + deserializedUserAssignedIdentity.principalId = reader.getString(); + } else if ("clientId".equals(fieldName)) { + deserializedUserAssignedIdentity.clientId = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedUserAssignedIdentity; + }); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/models/package-info.java new file mode 100644 index 0000000000000..5715eebd4cf41 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/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) TypeSpec Code Generator. + +/** + * Package containing the data models for MonitorAgents. + * Monitor Agents Management Client. + */ +package com.azure.resourcemanager.monitor.agents.models; diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/package-info.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/package-info.java new file mode 100644 index 0000000000000..449c3d04c68a8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/com/azure/resourcemanager/monitor/agents/package-info.java @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for MonitorAgents. + * Monitor Agents Management Client. + */ +package com.azure.resourcemanager.monitor.agents; diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/module-info.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/module-info.java new file mode 100644 index 0000000000000..8df315d6d72e1 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/java/module-info.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +module com.azure.resourcemanager.monitor.agents { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.monitor.agents; + exports com.azure.resourcemanager.monitor.agents.fluent; + exports com.azure.resourcemanager.monitor.agents.fluent.models; + exports com.azure.resourcemanager.monitor.agents.models; + + opens com.azure.resourcemanager.monitor.agents.fluent.models to com.azure.core; + opens com.azure.resourcemanager.monitor.agents.models to com.azure.core; + opens com.azure.resourcemanager.monitor.agents.implementation.models to com.azure.core; +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/azure-resourcemanager-monitor-agents_metadata.json b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/azure-resourcemanager-monitor-agents_metadata.json new file mode 100644 index 0000000000000..43ce1e8b921dd --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/azure-resourcemanager-monitor-agents_metadata.json @@ -0,0 +1 @@ +{"flavor":"azure","apiVersions":{"Microsoft.Monitor":"2026-05-01-preview"},"crossLanguagePackageId":"Microsoft.Monitor","crossLanguageVersion":"3b5f129a7d67","crossLanguageDefinitions":{"com.azure.resourcemanager.monitor.agents.fluent.MonitorAgentsManagementClient":"Microsoft.Monitor","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient":"Microsoft.Monitor.ObservabilityAgents","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.createOrUpdate":"Microsoft.Monitor.ObservabilityAgents.createOrUpdate","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.createOrUpdateWithResponse":"Microsoft.Monitor.ObservabilityAgents.createOrUpdate","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.delete":"Microsoft.Monitor.ObservabilityAgents.delete","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.deleteWithResponse":"Microsoft.Monitor.ObservabilityAgents.delete","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.getByResourceGroup":"Microsoft.Monitor.ObservabilityAgents.get","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.getByResourceGroupWithResponse":"Microsoft.Monitor.ObservabilityAgents.get","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.list":"Microsoft.Monitor.ObservabilityAgents.listBySubscription","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.listByResourceGroup":"Microsoft.Monitor.ObservabilityAgents.listByResourceGroup","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.update":"Microsoft.Monitor.ObservabilityAgents.update","com.azure.resourcemanager.monitor.agents.fluent.ObservabilityAgentsClient.updateWithResponse":"Microsoft.Monitor.ObservabilityAgents.update","com.azure.resourcemanager.monitor.agents.fluent.OperationsClient":"Microsoft.Monitor.Operations","com.azure.resourcemanager.monitor.agents.fluent.OperationsClient.list":"Azure.ResourceManager.Operations.list","com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner":"Microsoft.Monitor.ObservabilityAgentResource","com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner":"Azure.ResourceManager.CommonTypes.Operation","com.azure.resourcemanager.monitor.agents.implementation.MonitorAgentsManagementClientBuilder":"Microsoft.Monitor","com.azure.resourcemanager.monitor.agents.implementation.models.ObservabilityAgentResourceListResult":"Azure.ResourceManager.ResourceListResult","com.azure.resourcemanager.monitor.agents.implementation.models.OperationListResult":"Azure.ResourceManager.CommonTypes.OperationListResult","com.azure.resourcemanager.monitor.agents.models.ActionType":"Azure.ResourceManager.CommonTypes.ActionType","com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentity","com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType":"Azure.ResourceManager.CommonTypes.ManagedServiceIdentityType","com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPatch":"Microsoft.Monitor.ObservabilityAgentPatch","com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties":"Microsoft.Monitor.ObservabilityAgentProperties","com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPropertiesUpdate":"Microsoft.Monitor.ObservabilityAgentPropertiesUpdate","com.azure.resourcemanager.monitor.agents.models.OperationDisplay":"Azure.ResourceManager.CommonTypes.OperationDisplay","com.azure.resourcemanager.monitor.agents.models.OperationEntry":"Microsoft.Monitor.OperationEntry","com.azure.resourcemanager.monitor.agents.models.OperationMode":"Microsoft.Monitor.OperationMode","com.azure.resourcemanager.monitor.agents.models.OperationType":"Microsoft.Monitor.OperationType","com.azure.resourcemanager.monitor.agents.models.Origin":"Azure.ResourceManager.CommonTypes.Origin","com.azure.resourcemanager.monitor.agents.models.ResourceProvisioningState":"Azure.ResourceManager.ResourceProvisioningState","com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity":"Azure.ResourceManager.CommonTypes.UserAssignedIdentity"},"generatedFiles":["src/main/java/com/azure/resourcemanager/monitor/agents/MonitorAgentsManager.java","src/main/java/com/azure/resourcemanager/monitor/agents/fluent/MonitorAgentsManagementClient.java","src/main/java/com/azure/resourcemanager/monitor/agents/fluent/ObservabilityAgentsClient.java","src/main/java/com/azure/resourcemanager/monitor/agents/fluent/OperationsClient.java","src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/ObservabilityAgentResourceInner.java","src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/OperationInner.java","src/main/java/com/azure/resourcemanager/monitor/agents/fluent/models/package-info.java","src/main/java/com/azure/resourcemanager/monitor/agents/fluent/package-info.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientBuilder.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/MonitorAgentsManagementClientImpl.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentResourceImpl.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsClientImpl.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ObservabilityAgentsImpl.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationImpl.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsClientImpl.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/OperationsImpl.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/ResourceManagerUtils.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/ObservabilityAgentResourceListResult.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/models/OperationListResult.java","src/main/java/com/azure/resourcemanager/monitor/agents/implementation/package-info.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ActionType.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentity.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ManagedServiceIdentityType.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPatch.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentProperties.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentPropertiesUpdate.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgentResource.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ObservabilityAgents.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/Operation.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationDisplay.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationEntry.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationMode.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/OperationType.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/Operations.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/Origin.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/ResourceProvisioningState.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/UserAssignedIdentity.java","src/main/java/com/azure/resourcemanager/monitor/agents/models/package-info.java","src/main/java/com/azure/resourcemanager/monitor/agents/package-info.java","src/main/java/module-info.java"]} \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-agents/proxy-config.json b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-agents/proxy-config.json new file mode 100644 index 0000000000000..9c0897bbce10f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-agents/proxy-config.json @@ -0,0 +1 @@ +[["com.azure.resourcemanager.monitor.agents.implementation.ObservabilityAgentsClientImpl$ObservabilityAgentsService"],["com.azure.resourcemanager.monitor.agents.implementation.OperationsClientImpl$OperationsService"]] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-agents/reflect-config.json b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-agents/reflect-config.json new file mode 100644 index 0000000000000..0637a088a01e8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/META-INF/native-image/com.azure.resourcemanager/azure-resourcemanager-monitor-agents/reflect-config.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/azure-resourcemanager-monitor-agents.properties b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/azure-resourcemanager-monitor-agents.properties new file mode 100644 index 0000000000000..defbd48204e47 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/main/resources/azure-resourcemanager-monitor-agents.properties @@ -0,0 +1 @@ +version=${project.version} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsCreateOrUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsCreateOrUpdateSamples.java new file mode 100644 index 0000000000000..88cd8de02fef6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsCreateOrUpdateSamples.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ObservabilityAgents CreateOrUpdate. + */ +public final class ObservabilityAgentsCreateOrUpdateSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_CreateOrUpdate.json + */ + /** + * Sample code: ObservabilityAgents_CreateOrUpdate. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsCreateOrUpdate(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .define("myObservabilityAgent") + .withRegion("eastus") + .withExistingResourceGroup("myResourceGroup") + .withTags(mapOf("env", "dev")) + .withProperties(new ObservabilityAgentProperties().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace") + .withEnabled(true) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.AUTO) + .withInstructions("use includeAlertsFromGlobalRules"), + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.AUTO) + .withInstructions("focus on recent issues")))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity", + new UserAssignedIdentity()))) + .create(); + } + + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_CreateOrUpdate_MinimumSet.json + */ + /** + * Sample code: ObservabilityAgents_CreateOrUpdate_MinimumSet. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void observabilityAgentsCreateOrUpdateMinimumSet( + com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .define("myObservabilityAgent") + .withRegion("eastus") + .withExistingResourceGroup("myResourceGroup") + .withProperties(new ObservabilityAgentProperties().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity", + new UserAssignedIdentity()))) + .create(); + } + + // Use "Map.of" if available + @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/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsDeleteSamples.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsDeleteSamples.java new file mode 100644 index 0000000000000..ade441d6d9e43 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsDeleteSamples.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +/** + * Samples for ObservabilityAgents Delete. + */ +public final class ObservabilityAgentsDeleteSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Delete.json + */ + /** + * Sample code: ObservabilityAgents_Delete. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsDelete(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .deleteByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsGetByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsGetByResourceGroupSamples.java new file mode 100644 index 0000000000000..d430eb837c2f2 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsGetByResourceGroupSamples.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +/** + * Samples for ObservabilityAgents GetByResourceGroup. + */ +public final class ObservabilityAgentsGetByResourceGroupSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Get.json + */ + /** + * Sample code: ObservabilityAgents_Get. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void observabilityAgentsGet(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents() + .getByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", + com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListByResourceGroupSamples.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListByResourceGroupSamples.java new file mode 100644 index 0000000000000..22f992cb984b3 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListByResourceGroupSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +/** + * Samples for ObservabilityAgents ListByResourceGroup. + */ +public final class ObservabilityAgentsListByResourceGroupSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_ListByResourceGroup.json + */ + /** + * Sample code: ObservabilityAgents_ListByResourceGroup. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsListByResourceGroup(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents().listByResourceGroup("myResourceGroup", com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListSamples.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListSamples.java new file mode 100644 index 0000000000000..5cdb23e1cb90b --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListSamples.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +/** + * Samples for ObservabilityAgents List. + */ +public final class ObservabilityAgentsListSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_ListBySubscription.json + */ + /** + * Sample code: ObservabilityAgents_ListBySubscription. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsListBySubscription(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.observabilityAgents().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsUpdateSamples.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsUpdateSamples.java new file mode 100644 index 0000000000000..e380ef5878508 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsUpdateSamples.java @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPropertiesUpdate; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * Samples for ObservabilityAgents Update. + */ +public final class ObservabilityAgentsUpdateSamples { + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Update_MinimumSet.json + */ + /** + * Sample code: ObservabilityAgents_Update_MinimumSet. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsUpdateMinimumSet(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + ObservabilityAgentResource resource = manager.observabilityAgents() + .getByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withProperties(new ObservabilityAgentPropertiesUpdate().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace")) + .apply(); + } + + /* + * x-ms-original-file: 2026-05-01-preview/ObservabilityAgents_Update.json + */ + /** + * Sample code: ObservabilityAgents_Update. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void + observabilityAgentsUpdate(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + ObservabilityAgentResource resource = manager.observabilityAgents() + .getByResourceGroupWithResponse("myResourceGroup", "myObservabilityAgent", com.azure.core.util.Context.NONE) + .getValue(); + resource.update() + .withTags(mapOf("env", "prod")) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities(mapOf( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity", + new UserAssignedIdentity()))) + .withProperties(new ObservabilityAgentPropertiesUpdate().withMonitoringAccountId( + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Monitor/accounts/myAzureMonitorWorkspace") + .withEnabled(false) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.MANUAL) + .withInstructions("Focus on storage and networking issues only."), + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.AUTO) + .withInstructions("Focus on recent network issues.")))) + .apply(); + } + + // Use "Map.of" if available + @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/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/OperationsListSamples.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/OperationsListSamples.java new file mode 100644 index 0000000000000..58001e2944fff --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/samples/java/com/azure/resourcemanager/monitor/agents/generated/OperationsListSamples.java @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +/** + * Samples for Operations List. + */ +public final class OperationsListSamples { + /* + * x-ms-original-file: 2026-05-01-preview/Operations_List.json + */ + /** + * Sample code: Operations_List. + * + * @param manager Entry point to MonitorAgentsManager. + */ + public static void operationsList(com.azure.resourcemanager.monitor.agents.MonitorAgentsManager manager) { + manager.operations().list(com.azure.core.util.Context.NONE); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ManagedServiceIdentityTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ManagedServiceIdentityTests.java new file mode 100644 index 0000000000000..54f11cec8bea5 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ManagedServiceIdentityTests.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ManagedServiceIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ManagedServiceIdentity model = BinaryData.fromString( + "{\"principalId\":\"trg\",\"tenantId\":\"bpf\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"np\":{\"principalId\":\"zgvfcjrwz\",\"clientId\":\"xjtfelluwfzit\"},\"xypininmayhuybbk\":{\"principalId\":\"fpjkjlxofp\",\"clientId\":\"hpf\"}}}") + .toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ManagedServiceIdentity model + = new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED) + .withUserAssignedIdentities( + mapOf("np", new UserAssignedIdentity(), "xypininmayhuybbk", new UserAssignedIdentity())); + model = BinaryData.fromObject(model).toObject(ManagedServiceIdentity.class); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.type()); + } + + // Use "Map.of" if available + @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/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPatchTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPatchTests.java new file mode 100644 index 0000000000000..ce315f99012e6 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPatchTests.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPatch; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPropertiesUpdate; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ObservabilityAgentPatchTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ObservabilityAgentPatch model = BinaryData.fromString( + "{\"tags\":{\"un\":\"tusivyevcciqihn\"},\"identity\":{\"principalId\":\"jzrnf\",\"tenantId\":\"xgispemvtzfkufu\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"ybkzgcwr\":{\"principalId\":\"xqeofjaeqjhqjba\",\"clientId\":\"msmjqulngsntn\"}}},\"properties\":{\"monitoringAccountId\":\"xxwr\",\"enabled\":true,\"operations\":[{\"type\":\"Investigation\",\"mode\":\"Manual\",\"instructions\":\"vkocrcjdkwtn\"},{\"type\":\"Investigation\",\"mode\":\"Manual\",\"instructions\":\"biksq\"},{\"type\":\"IssueCreation\",\"mode\":\"Manual\",\"instructions\":\"ainqpjwnzlljfm\"}]}}") + .toObject(ObservabilityAgentPatch.class); + Assertions.assertEquals("tusivyevcciqihn", model.tags().get("un")); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type()); + Assertions.assertEquals("xxwr", model.properties().monitoringAccountId()); + Assertions.assertTrue(model.properties().enabled()); + Assertions.assertEquals(OperationType.INVESTIGATION, model.properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.MANUAL, model.properties().operations().get(0).mode()); + Assertions.assertEquals("vkocrcjdkwtn", model.properties().operations().get(0).instructions()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ObservabilityAgentPatch model = new ObservabilityAgentPatch().withTags(mapOf("un", "tusivyevcciqihn")) + .withIdentity( + new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED) + .withUserAssignedIdentities(mapOf("ybkzgcwr", new UserAssignedIdentity()))) + .withProperties(new ObservabilityAgentPropertiesUpdate().withMonitoringAccountId("xxwr") + .withEnabled(true) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.MANUAL) + .withInstructions("vkocrcjdkwtn"), + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.MANUAL) + .withInstructions("biksq"), + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.MANUAL) + .withInstructions("ainqpjwnzlljfm")))); + model = BinaryData.fromObject(model).toObject(ObservabilityAgentPatch.class); + Assertions.assertEquals("tusivyevcciqihn", model.tags().get("un")); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, model.identity().type()); + Assertions.assertEquals("xxwr", model.properties().monitoringAccountId()); + Assertions.assertTrue(model.properties().enabled()); + Assertions.assertEquals(OperationType.INVESTIGATION, model.properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.MANUAL, model.properties().operations().get(0).mode()); + Assertions.assertEquals("vkocrcjdkwtn", model.properties().operations().get(0).instructions()); + } + + // Use "Map.of" if available + @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/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPropertiesTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPropertiesTests.java new file mode 100644 index 0000000000000..3fa0e088c1d61 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPropertiesTests.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class ObservabilityAgentPropertiesTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ObservabilityAgentProperties model = BinaryData.fromString( + "{\"provisioningState\":\"Succeeded\",\"monitoringAccountId\":\"ryo\",\"enabled\":true,\"operations\":[{\"type\":\"Investigation\",\"mode\":\"Auto\",\"instructions\":\"zakljlahbc\"},{\"type\":\"IssueCreation\",\"mode\":\"Manual\",\"instructions\":\"fdosyg\"},{\"type\":\"Investigation\",\"mode\":\"Manual\",\"instructions\":\"jakhmsbzjh\"}]}") + .toObject(ObservabilityAgentProperties.class); + Assertions.assertEquals("ryo", model.monitoringAccountId()); + Assertions.assertTrue(model.enabled()); + Assertions.assertEquals(OperationType.INVESTIGATION, model.operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, model.operations().get(0).mode()); + Assertions.assertEquals("zakljlahbc", model.operations().get(0).instructions()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ObservabilityAgentProperties model = new ObservabilityAgentProperties().withMonitoringAccountId("ryo") + .withEnabled(true) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.AUTO) + .withInstructions("zakljlahbc"), + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.MANUAL) + .withInstructions("fdosyg"), + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.MANUAL) + .withInstructions("jakhmsbzjh"))); + model = BinaryData.fromObject(model).toObject(ObservabilityAgentProperties.class); + Assertions.assertEquals("ryo", model.monitoringAccountId()); + Assertions.assertTrue(model.enabled()); + Assertions.assertEquals(OperationType.INVESTIGATION, model.operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, model.operations().get(0).mode()); + Assertions.assertEquals("zakljlahbc", model.operations().get(0).instructions()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPropertiesUpdateTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPropertiesUpdateTests.java new file mode 100644 index 0000000000000..2ea895b1aadb8 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentPropertiesUpdateTests.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentPropertiesUpdate; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; + +public final class ObservabilityAgentPropertiesUpdateTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ObservabilityAgentPropertiesUpdate model = BinaryData.fromString( + "{\"monitoringAccountId\":\"eebvmgxsab\",\"enabled\":true,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"c\"},{\"type\":\"IssueCreation\",\"mode\":\"Manual\",\"instructions\":\"evndh\"}]}") + .toObject(ObservabilityAgentPropertiesUpdate.class); + Assertions.assertEquals("eebvmgxsab", model.monitoringAccountId()); + Assertions.assertTrue(model.enabled()); + Assertions.assertEquals(OperationType.ISSUE_CREATION, model.operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, model.operations().get(0).mode()); + Assertions.assertEquals("c", model.operations().get(0).instructions()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ObservabilityAgentPropertiesUpdate model + = new ObservabilityAgentPropertiesUpdate().withMonitoringAccountId("eebvmgxsab") + .withEnabled(true) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.AUTO) + .withInstructions("c"), + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.MANUAL) + .withInstructions("evndh"))); + model = BinaryData.fromObject(model).toObject(ObservabilityAgentPropertiesUpdate.class); + Assertions.assertEquals("eebvmgxsab", model.monitoringAccountId()); + Assertions.assertTrue(model.enabled()); + Assertions.assertEquals(OperationType.ISSUE_CREATION, model.operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, model.operations().get(0).mode()); + Assertions.assertEquals("c", model.operations().get(0).instructions()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentResourceInnerTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentResourceInnerTests.java new file mode 100644 index 0000000000000..edeb8ea507a09 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentResourceInnerTests.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.fluent.models.ObservabilityAgentResourceInner; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public final class ObservabilityAgentResourceInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ObservabilityAgentResourceInner model = BinaryData.fromString( + "{\"properties\":{\"provisioningState\":\"Canceled\",\"monitoringAccountId\":\"bpzvgn\",\"enabled\":true,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Manual\",\"instructions\":\"fcyzkohdbihanufh\"},{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"s\"}]},\"identity\":{\"principalId\":\"th\",\"tenantId\":\"hab\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"ybrk\":{\"principalId\":\"xwczbyscnp\",\"clientId\":\"uhivyqniw\"},\"cnyejhkryhtnapcz\":{\"principalId\":\"dumjgrtfwvuk\",\"clientId\":\"audccsnhs\"}}},\"location\":\"okjye\",\"tags\":{\"jnchgej\":\"vnipjox\",\"huxinpmqnj\":\"podmailzydehojwy\",\"vcputegj\":\"qwixjspro\"},\"id\":\"wmfdatscmdvpjhul\",\"name\":\"uuvmkjozkrwfnd\",\"type\":\"odjpslwejd\"}") + .toObject(ObservabilityAgentResourceInner.class); + Assertions.assertEquals("okjye", model.location()); + Assertions.assertEquals("vnipjox", model.tags().get("jnchgej")); + Assertions.assertEquals("bpzvgn", model.properties().monitoringAccountId()); + Assertions.assertTrue(model.properties().enabled()); + Assertions.assertEquals(OperationType.ISSUE_CREATION, model.properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.MANUAL, model.properties().operations().get(0).mode()); + Assertions.assertEquals("fcyzkohdbihanufh", model.properties().operations().get(0).instructions()); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.identity().type()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + ObservabilityAgentResourceInner model = new ObservabilityAgentResourceInner().withLocation("okjye") + .withTags(mapOf("jnchgej", "vnipjox", "huxinpmqnj", "podmailzydehojwy", "vcputegj", "qwixjspro")) + .withProperties(new ObservabilityAgentProperties().withMonitoringAccountId("bpzvgn") + .withEnabled(true) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.MANUAL) + .withInstructions("fcyzkohdbihanufh"), + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.AUTO) + .withInstructions("s")))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.USER_ASSIGNED) + .withUserAssignedIdentities( + mapOf("ybrk", new UserAssignedIdentity(), "cnyejhkryhtnapcz", new UserAssignedIdentity()))); + model = BinaryData.fromObject(model).toObject(ObservabilityAgentResourceInner.class); + Assertions.assertEquals("okjye", model.location()); + Assertions.assertEquals("vnipjox", model.tags().get("jnchgej")); + Assertions.assertEquals("bpzvgn", model.properties().monitoringAccountId()); + Assertions.assertTrue(model.properties().enabled()); + Assertions.assertEquals(OperationType.ISSUE_CREATION, model.properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.MANUAL, model.properties().operations().get(0).mode()); + Assertions.assertEquals("fcyzkohdbihanufh", model.properties().operations().get(0).instructions()); + Assertions.assertEquals(ManagedServiceIdentityType.USER_ASSIGNED, model.identity().type()); + } + + // Use "Map.of" if available + @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/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentResourceListResultTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentResourceListResultTests.java new file mode 100644 index 0000000000000..7af5de67e9cc7 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentResourceListResultTests.java @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.implementation.models.ObservabilityAgentResourceListResult; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import org.junit.jupiter.api.Assertions; + +public final class ObservabilityAgentResourceListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + ObservabilityAgentResourceListResult model = BinaryData.fromString( + "{\"value\":[{\"properties\":{\"provisioningState\":\"Succeeded\",\"monitoringAccountId\":\"appd\",\"enabled\":true,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Manual\",\"instructions\":\"feusnhut\"},{\"type\":\"Investigation\",\"mode\":\"Manual\",\"instructions\":\"rl\"}]},\"identity\":{\"principalId\":\"gjzzdatqxhocdg\",\"tenantId\":\"blgphuticn\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"wcukjfkgiawxk\":{\"principalId\":\"zwyiftyhxhur\",\"clientId\":\"ftyxolniw\"},\"dhsgcba\":{\"principalId\":\"ypl\",\"clientId\":\"kbasyypn\"},\"yqkgfg\":{\"principalId\":\"hejkotynqgou\",\"clientId\":\"ndlik\"},\"mnkzsmod\":{\"principalId\":\"madgakeqsrxyb\",\"clientId\":\"qedqytbciqfoufl\"}}},\"location\":\"lougpbkw\",\"tags\":{\"umkdosvqwhbmd\":\"tduqktapspwgcuer\",\"bhtqqrolfpfpsa\":\"bbjfddgmbmbexp\",\"jgzjaoyfhrtx\":\"gbquxigj\",\"fqawrlyxw\":\"lnerkujysvleju\"},\"id\":\"kcprbnw\",\"name\":\"xgjvtbv\",\"type\":\"ysszdnrujqguh\"},{\"properties\":{\"provisioningState\":\"Succeeded\",\"monitoringAccountId\":\"qfprwzwbn\",\"enabled\":true,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"gazxuf\"}]},\"identity\":{\"principalId\":\"ckyfih\",\"tenantId\":\"idf\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"wxmnteiwao\":{\"principalId\":\"uht\",\"clientId\":\"wisdkft\"},\"mxdcufufsrp\":{\"principalId\":\"km\",\"clientId\":\"c\"},\"mdwzjeiachboo\":{\"principalId\":\"zidnsezcxtbzsgfy\",\"clientId\":\"sne\"}}},\"location\":\"lnrosfqp\",\"tags\":{\"i\":\"hzzvypyq\",\"npvswjdkirso\":\"z\",\"soifiyipjxsqw\":\"dqxhcrmnohjtckwh\"},\"id\":\"gr\",\"name\":\"bznorcjxvsnby\",\"type\":\"qabnmoc\"},{\"properties\":{\"provisioningState\":\"Canceled\",\"monitoringAccountId\":\"hurzafblj\",\"enabled\":true,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"mkljavb\"},{\"type\":\"Investigation\",\"mode\":\"Manual\",\"instructions\":\"ajzyul\"},{\"type\":\"Investigation\",\"mode\":\"Auto\",\"instructions\":\"krlkhbzhfepg\"}]},\"identity\":{\"principalId\":\"e\",\"tenantId\":\"locx\",\"type\":\"None\",\"userAssignedIdentities\":{\"xkqpxo\":{\"principalId\":\"erhhbcsglumm\",\"clientId\":\"tjaodxobnb\"},\"aajrm\":{\"principalId\":\"jionpimexgstxgc\",\"clientId\":\"dg\"}}},\"location\":\"jwzrl\",\"tags\":{\"qsqsy\":\"clwhijcoejctbz\"},\"id\":\"bkbfkgukdkex\",\"name\":\"ppofmxaxcfjpgdd\",\"type\":\"ocjjxhvpmouexh\"},{\"properties\":{\"provisioningState\":\"Canceled\",\"monitoringAccountId\":\"bqe\",\"enabled\":true,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"dntwndeicbtw\"},{\"type\":\"Investigation\",\"mode\":\"Auto\",\"instructions\":\"qvuhrhcffcyddglm\"},{\"type\":\"IssueCreation\",\"mode\":\"Manual\",\"instructions\":\"kw\"}]},\"identity\":{\"principalId\":\"icxm\",\"tenantId\":\"iwqvhkh\",\"type\":\"UserAssigned\",\"userAssignedIdentities\":{\"uhrzayvvt\":{\"principalId\":\"dtopbob\",\"clientId\":\"ghmewuam\"},\"efgugnxk\":{\"principalId\":\"vdfgiotk\",\"clientId\":\"utqxlngx\"},\"hjybigehoqfbo\":{\"principalId\":\"dqmidtt\",\"clientId\":\"rvqdra\"}}},\"location\":\"kanyktzlcuiywg\",\"tags\":{\"gpphrcgyn\":\"gndrvynh\",\"fsxlzevgbmqjqa\":\"ocpecfvmmco\",\"pmivkwlzu\":\"c\",\"ebxetqgtzxdp\":\"ccfwnfnbacfion\"},\"id\":\"qbqqwxr\",\"name\":\"feallnwsu\",\"type\":\"isnjampmngnz\"}],\"nextLink\":\"xaqwoochcbonqv\"}") + .toObject(ObservabilityAgentResourceListResult.class); + Assertions.assertEquals("lougpbkw", model.value().get(0).location()); + Assertions.assertEquals("tduqktapspwgcuer", model.value().get(0).tags().get("umkdosvqwhbmd")); + Assertions.assertEquals("appd", model.value().get(0).properties().monitoringAccountId()); + Assertions.assertTrue(model.value().get(0).properties().enabled()); + Assertions.assertEquals(OperationType.ISSUE_CREATION, + model.value().get(0).properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.MANUAL, model.value().get(0).properties().operations().get(0).mode()); + Assertions.assertEquals("feusnhut", model.value().get(0).properties().operations().get(0).instructions()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, + model.value().get(0).identity().type()); + Assertions.assertEquals("xaqwoochcbonqv", model.nextLink()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsCreateOrUpdateWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsCreateOrUpdateWithResponseMockTests.java new file mode 100644 index 0000000000000..2120f91ba0b7f --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsCreateOrUpdateWithResponseMockTests.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.agents.MonitorAgentsManager; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentity; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentProperties; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class ObservabilityAgentsCreateOrUpdateWithResponseMockTests { + @Test + public void testCreateOrUpdateWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Failed\",\"monitoringAccountId\":\"ibnuqqkpik\",\"enabled\":false,\"operations\":[{\"type\":\"Investigation\",\"mode\":\"Auto\",\"instructions\":\"n\"}]},\"identity\":{\"principalId\":\"nhijggmebfsi\",\"tenantId\":\"butr\",\"type\":\"SystemAssigned\",\"userAssignedIdentities\":{\"henbtkcxywnytn\":{\"principalId\":\"zzmhjrunmpxttd\",\"clientId\":\"rbnlankxmyskp\"}}},\"location\":\"yn\",\"tags\":{\"dbabp\":\"dybyxczfclhaa\",\"fkts\":\"lwrq\",\"nyyazttbtwwrqpue\":\"hsucoc\"},\"id\":\"ckzywbiexzfeyue\",\"name\":\"xibxujwbhqwalm\",\"type\":\"zyoxaepdkzjan\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + MonitorAgentsManager manager = MonitorAgentsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + ObservabilityAgentResource response = manager.observabilityAgents() + .define("ntypmrbpizcdrqj") + .withRegion("brjcxe") + .withExistingResourceGroup("gukgjnpiucgygevq") + .withTags(mapOf("phxepcyvahf", "wutttxfvjrbi", "gidokgjljyoxgvcl", "ljkyqxjvuuj", "jhtxfvgxbfsmxne", + "bgsncghkjeszzhb", "rbmpukgri", "mpvecxgodebfqk")) + .withProperties(new ObservabilityAgentProperties().withMonitoringAccountId("dnfyhxdeoejzicwi") + .withEnabled(false) + .withOperations(Arrays.asList( + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.MANUAL) + .withInstructions("ishc"), + new OperationEntry().withType(OperationType.ISSUE_CREATION) + .withMode(OperationMode.MANUAL) + .withInstructions("deyeamdphagalpbu"), + new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.MANUAL) + .withInstructions("whonowk")))) + .withIdentity(new ManagedServiceIdentity().withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED) + .withUserAssignedIdentities( + mapOf("ryavwhheunmmqh", new UserAssignedIdentity(), "szfkbe", new UserAssignedIdentity(), + "frzpwvlqdqgb", new UserAssignedIdentity(), "jf", new UserAssignedIdentity()))) + .create(); + + Assertions.assertEquals("yn", response.location()); + Assertions.assertEquals("dybyxczfclhaa", response.tags().get("dbabp")); + Assertions.assertEquals("ibnuqqkpik", response.properties().monitoringAccountId()); + Assertions.assertFalse(response.properties().enabled()); + Assertions.assertEquals(OperationType.INVESTIGATION, response.properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, response.properties().operations().get(0).mode()); + Assertions.assertEquals("n", response.properties().operations().get(0).instructions()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED, response.identity().type()); + } + + // Use "Map.of" if available + @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/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsDeleteByResourceGroupWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsDeleteByResourceGroupWithResponseMockTests.java new file mode 100644 index 0000000000000..f9759cebf8c34 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsDeleteByResourceGroupWithResponseMockTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.agents.MonitorAgentsManager; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class ObservabilityAgentsDeleteByResourceGroupWithResponseMockTests { + @Test + public void testDeleteWithResponse() throws Exception { + String responseStr = "{}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + MonitorAgentsManager manager = MonitorAgentsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + manager.observabilityAgents() + .deleteByResourceGroupWithResponse("jpkcattpng", "cr", com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsGetByResourceGroupWithResponseMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsGetByResourceGroupWithResponseMockTests.java new file mode 100644 index 0000000000000..462027562f076 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsGetByResourceGroupWithResponseMockTests.java @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.agents.MonitorAgentsManager; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class ObservabilityAgentsGetByResourceGroupWithResponseMockTests { + @Test + public void testGetByResourceGroupWithResponse() throws Exception { + String responseStr + = "{\"properties\":{\"provisioningState\":\"Succeeded\",\"monitoringAccountId\":\"lfh\",\"enabled\":false,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"lbjnpgacftadehx\"},{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"sop\"},{\"type\":\"IssueCreation\",\"mode\":\"Manual\",\"instructions\":\"snzwd\"}]},\"identity\":{\"principalId\":\"avo\",\"tenantId\":\"zdmohctbqvu\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"zj\":{\"principalId\":\"dnvowg\",\"clientId\":\"jugwdkcglhsl\"},\"n\":{\"principalId\":\"ggd\",\"clientId\":\"ixhbkuofqweykhm\"}}},\"location\":\"fyexfwhy\",\"tags\":{\"naamde\":\"bvyvdcsity\"},\"id\":\"tehfiqscjeypvh\",\"name\":\"zrkgqhcjrefovg\",\"type\":\"kqsleyyvxy\"}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + MonitorAgentsManager manager = MonitorAgentsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + ObservabilityAgentResource response = manager.observabilityAgents() + .getByResourceGroupWithResponse("e", "jzzvdud", com.azure.core.util.Context.NONE) + .getValue(); + + Assertions.assertEquals("fyexfwhy", response.location()); + Assertions.assertEquals("bvyvdcsity", response.tags().get("naamde")); + Assertions.assertEquals("lfh", response.properties().monitoringAccountId()); + Assertions.assertFalse(response.properties().enabled()); + Assertions.assertEquals(OperationType.ISSUE_CREATION, response.properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, response.properties().operations().get(0).mode()); + Assertions.assertEquals("lbjnpgacftadehx", response.properties().operations().get(0).instructions()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, response.identity().type()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListByResourceGroupMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListByResourceGroupMockTests.java new file mode 100644 index 0000000000000..919d82f9154bf --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListByResourceGroupMockTests.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.agents.MonitorAgentsManager; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class ObservabilityAgentsListByResourceGroupMockTests { + @Test + public void testListByResourceGroup() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Canceled\",\"monitoringAccountId\":\"nysounqe\",\"enabled\":false,\"operations\":[{\"type\":\"Investigation\",\"mode\":\"Auto\",\"instructions\":\"hy\"}]},\"identity\":{\"principalId\":\"rpmopjmc\",\"tenantId\":\"tuo\",\"type\":\"SystemAssigned,UserAssigned\",\"userAssignedIdentities\":{\"ozmyzydagfu\":{\"principalId\":\"iuaod\",\"clientId\":\"cpkvxodp\"}}},\"location\":\"bezy\",\"tags\":{\"ywqsmbsurexim\":\"kktwhrdxw\",\"stkiiuxhqyud\":\"ryocfsfksymdd\",\"rq\":\"o\"},\"id\":\"b\",\"name\":\"oczvy\",\"type\":\"fqrvkdvjsllrmvvd\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + MonitorAgentsManager manager = MonitorAgentsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response + = manager.observabilityAgents().listByResourceGroup("czsqpjhvm", com.azure.core.util.Context.NONE); + + Assertions.assertEquals("bezy", response.iterator().next().location()); + Assertions.assertEquals("kktwhrdxw", response.iterator().next().tags().get("ywqsmbsurexim")); + Assertions.assertEquals("nysounqe", response.iterator().next().properties().monitoringAccountId()); + Assertions.assertFalse(response.iterator().next().properties().enabled()); + Assertions.assertEquals(OperationType.INVESTIGATION, + response.iterator().next().properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, response.iterator().next().properties().operations().get(0).mode()); + Assertions.assertEquals("hy", response.iterator().next().properties().operations().get(0).instructions()); + Assertions.assertEquals(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED, + response.iterator().next().identity().type()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListMockTests.java new file mode 100644 index 0000000000000..27e87b8a43a28 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/ObservabilityAgentsListMockTests.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.agents.MonitorAgentsManager; +import com.azure.resourcemanager.monitor.agents.models.ManagedServiceIdentityType; +import com.azure.resourcemanager.monitor.agents.models.ObservabilityAgentResource; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class ObservabilityAgentsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"properties\":{\"provisioningState\":\"Failed\",\"monitoringAccountId\":\"kpnpulexxbczwtr\",\"enabled\":false,\"operations\":[{\"type\":\"IssueCreation\",\"mode\":\"Auto\",\"instructions\":\"sovmyokacspkwl\"}]},\"identity\":{\"principalId\":\"obpxjmflbvvn\",\"tenantId\":\"rkcciwwzjuqk\",\"type\":\"None\",\"userAssignedIdentities\":{\"ugidyjrr\":{\"principalId\":\"iwkuofos\",\"clientId\":\"hsauuimjmvxied\"},\"slkevle\":{\"principalId\":\"y\",\"clientId\":\"svexcsonpclhoco\"}}},\"location\":\"zfbuhf\",\"tags\":{\"th\":\"axkffei\",\"shxmzsbbzoggigrx\":\"vmezy\",\"ptkoenkoukn\":\"burvjxxjnspy\"},\"id\":\"udwtiukbl\",\"name\":\"ngkpocipazy\",\"type\":\"o\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + MonitorAgentsManager manager = MonitorAgentsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response + = manager.observabilityAgents().list(com.azure.core.util.Context.NONE); + + Assertions.assertEquals("zfbuhf", response.iterator().next().location()); + Assertions.assertEquals("axkffei", response.iterator().next().tags().get("th")); + Assertions.assertEquals("kpnpulexxbczwtr", response.iterator().next().properties().monitoringAccountId()); + Assertions.assertFalse(response.iterator().next().properties().enabled()); + Assertions.assertEquals(OperationType.ISSUE_CREATION, + response.iterator().next().properties().operations().get(0).type()); + Assertions.assertEquals(OperationMode.AUTO, response.iterator().next().properties().operations().get(0).mode()); + Assertions.assertEquals("sovmyokacspkwl", + response.iterator().next().properties().operations().get(0).instructions()); + Assertions.assertEquals(ManagedServiceIdentityType.NONE, response.iterator().next().identity().type()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationDisplayTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationDisplayTests.java new file mode 100644 index 0000000000000..682569cd4b854 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationDisplayTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.models.OperationDisplay; + +public final class OperationDisplayTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationDisplay model = BinaryData.fromString( + "{\"provider\":\"cdm\",\"resource\":\"rcryuanzwuxzdxta\",\"operation\":\"lhmwhfpmrqobm\",\"description\":\"kknryrtihf\"}") + .toObject(OperationDisplay.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationEntryTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationEntryTests.java new file mode 100644 index 0000000000000..03a778ea55990 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationEntryTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.models.OperationEntry; +import com.azure.resourcemanager.monitor.agents.models.OperationMode; +import com.azure.resourcemanager.monitor.agents.models.OperationType; +import org.junit.jupiter.api.Assertions; + +public final class OperationEntryTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationEntry model + = BinaryData.fromString("{\"type\":\"Investigation\",\"mode\":\"Manual\",\"instructions\":\"dphlxaolt\"}") + .toObject(OperationEntry.class); + Assertions.assertEquals(OperationType.INVESTIGATION, model.type()); + Assertions.assertEquals(OperationMode.MANUAL, model.mode()); + Assertions.assertEquals("dphlxaolt", model.instructions()); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + OperationEntry model = new OperationEntry().withType(OperationType.INVESTIGATION) + .withMode(OperationMode.MANUAL) + .withInstructions("dphlxaolt"); + model = BinaryData.fromObject(model).toObject(OperationEntry.class); + Assertions.assertEquals(OperationType.INVESTIGATION, model.type()); + Assertions.assertEquals(OperationMode.MANUAL, model.mode()); + Assertions.assertEquals("dphlxaolt", model.instructions()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationInnerTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationInnerTests.java new file mode 100644 index 0000000000000..52ac5f10dd4b0 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationInnerTests.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.fluent.models.OperationInner; + +public final class OperationInnerTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationInner model = BinaryData.fromString( + "{\"name\":\"nygj\",\"isDataAction\":true,\"display\":{\"provider\":\"eqsrdeupewnwreit\",\"resource\":\"yflusarhmofc\",\"operation\":\"smy\",\"description\":\"kdtmlxhekuk\"},\"origin\":\"user,system\",\"actionType\":\"Internal\"}") + .toObject(OperationInner.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationListResultTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationListResultTests.java new file mode 100644 index 0000000000000..8fc0d3d8f0307 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationListResultTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.implementation.models.OperationListResult; +import org.junit.jupiter.api.Assertions; + +public final class OperationListResultTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + OperationListResult model = BinaryData.fromString( + "{\"value\":[{\"name\":\"hq\",\"isDataAction\":true,\"display\":{\"provider\":\"pybczmehmtzopb\",\"resource\":\"h\",\"operation\":\"pidgsybbejhphoyc\",\"description\":\"xaobhdxbmtqioqjz\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"fpownoizhwlr\",\"isDataAction\":false,\"display\":{\"provider\":\"oqijgkdmbpaz\",\"resource\":\"bc\",\"operation\":\"pdznrbtcqqjnqgl\",\"description\":\"gnufoooj\"},\"origin\":\"system\",\"actionType\":\"Internal\"},{\"name\":\"esaagdfm\",\"isDataAction\":true,\"display\":{\"provider\":\"j\",\"resource\":\"ifkwmrvktsizntoc\",\"operation\":\"a\",\"description\":\"ajpsquc\"},\"origin\":\"system\",\"actionType\":\"Internal\"}],\"nextLink\":\"kfo\"}") + .toObject(OperationListResult.class); + Assertions.assertEquals("kfo", model.nextLink()); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationsListMockTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationsListMockTests.java new file mode 100644 index 0000000000000..7575602789b36 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/OperationsListMockTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.credential.AccessToken; +import com.azure.core.http.HttpClient; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.models.AzureCloud; +import com.azure.core.test.http.MockHttpResponse; +import com.azure.resourcemanager.monitor.agents.MonitorAgentsManager; +import com.azure.resourcemanager.monitor.agents.models.Operation; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +public final class OperationsListMockTests { + @Test + public void testList() throws Exception { + String responseStr + = "{\"value\":[{\"name\":\"vlrxnjeaseiph\",\"isDataAction\":false,\"display\":{\"provider\":\"keyyi\",\"resource\":\"jbdlwtgrhpdjpju\",\"operation\":\"sxazjpq\",\"description\":\"gual\"},\"origin\":\"user\",\"actionType\":\"Internal\"}]}"; + + HttpClient httpClient + = response -> Mono.just(new MockHttpResponse(response, 200, responseStr.getBytes(StandardCharsets.UTF_8))); + MonitorAgentsManager manager = MonitorAgentsManager.configure() + .withHttpClient(httpClient) + .authenticate(tokenRequestContext -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)), + new AzureProfile("", "", AzureCloud.AZURE_PUBLIC_CLOUD)); + + PagedIterable response = manager.operations().list(com.azure.core.util.Context.NONE); + + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/UserAssignedIdentityTests.java b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/UserAssignedIdentityTests.java new file mode 100644 index 0000000000000..f2739d4872081 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/src/test/java/com/azure/resourcemanager/monitor/agents/generated/UserAssignedIdentityTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.azure.resourcemanager.monitor.agents.generated; + +import com.azure.core.util.BinaryData; +import com.azure.resourcemanager.monitor.agents.models.UserAssignedIdentity; + +public final class UserAssignedIdentityTests { + @org.junit.jupiter.api.Test + public void testDeserialize() throws Exception { + UserAssignedIdentity model + = BinaryData.fromString("{\"principalId\":\"depoog\",\"clientId\":\"uvamiheognarxzxt\"}") + .toObject(UserAssignedIdentity.class); + } + + @org.junit.jupiter.api.Test + public void testSerialize() throws Exception { + UserAssignedIdentity model = new UserAssignedIdentity(); + model = BinaryData.fromObject(model).toObject(UserAssignedIdentity.class); + } +} diff --git a/sdk/monitor/azure-resourcemanager-monitor-agents/tsp-location.yaml b/sdk/monitor/azure-resourcemanager-monitor-agents/tsp-location.yaml new file mode 100644 index 0000000000000..d3cb156e00282 --- /dev/null +++ b/sdk/monitor/azure-resourcemanager-monitor-agents/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/monitoringservice/resource-manager/Microsoft.Monitor/Agents +commit: cd9789e9cfdb4cd052f4dbe14ee0c4139ada6c7b +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/monitor/ci.yml b/sdk/monitor/ci.yml index fd9c88188f4df..4e7bdd1fe567c 100644 --- a/sdk/monitor/ci.yml +++ b/sdk/monitor/ci.yml @@ -82,6 +82,10 @@ parameters: displayName: azure-resourcemanager-monitor-workspaces type: boolean default: false + - name: release_azureresourcemanagermonitoragents + displayName: azure-resourcemanager-monitor-agents + type: boolean + default: false extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -124,6 +128,10 @@ extends: groupId: com.azure.resourcemanager safeName: azureresourcemanagermonitorworkspaces releaseInBatch: ${{ parameters.release_azureresourcemanagermonitorworkspaces }} + - name: azure-resourcemanager-monitor-agents + groupId: com.azure.resourcemanager + safeName: azureresourcemanagermonitoragents + releaseInBatch: ${{ parameters.release_azureresourcemanagermonitoragents }} AdditionalModules: - name: azure-monitor-query-perf groupId: com.azure diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index 836b326a6e320..b3cca76223cbf 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -19,6 +19,7 @@ azure-monitor-query-metrics azure-monitor-query-perf azure-resourcemanager-monitor + azure-resourcemanager-monitor-agents azure-resourcemanager-monitor-slis azure-resourcemanager-monitor-workspaces