diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 14f1a970e4e3..c1f033137d27 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -276,6 +276,7 @@ com.azure.resourcemanager:azure-resourcemanager-datalakestore;1.0.0-beta.1;1.0.0 com.azure.resourcemanager:azure-resourcemanager-iotcentral;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-labservices;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-vmwarecloudsimple;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-marketplacenotifications;1.0.0-beta.1;1.0.0-beta.1 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current # version. Unreleased dependencies are only valid for dependency versions. diff --git a/pom.xml b/pom.xml index 911b8d8d0264..1c9255684aa1 100644 --- a/pom.xml +++ b/pom.xml @@ -721,6 +721,7 @@ sdk/machinelearningservices sdk/maintenance sdk/mariadb + sdk/marketplacenotifications sdk/marketplaceordering sdk/mediaservices sdk/metricsadvisor diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/CHANGELOG.md b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/CHANGELOG.md new file mode 100644 index 000000000000..91a5c0a5186f --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-04-25) + +- Azure Resource Manager Marketplacenotifications client library for Java. This package contains Microsoft Azure SDK for Marketplacenotifications Management SDK. Description of the new service. Package tag package-2021-03-03. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/README.md b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/README.md new file mode 100644 index 000000000000..e0b00cae19bf --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/README.md @@ -0,0 +1,99 @@ +# Azure Resource Manager Marketplacenotifications client library for Java + +Azure Resource Manager Marketplacenotifications client library for Java. + +This package contains Microsoft Azure SDK for Marketplacenotifications Management SDK. Description of the new service. Package tag package-2021-03-03. 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-marketplacenotifications;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-marketplacenotifications + 1.0.0-beta.1 + +``` +[//]: # ({x-version-update-end}) + +### Include the recommended packages + +Azure Management Libraries require a `TokenCredential` implementation for authentication and an `HttpClient` implementation for HTTP client. + +[Azure Identity][azure_identity] package and [Azure Core Netty HTTP][azure_core_http_netty] package provide the default implementation. + +### Authentication + +By default, Azure Active Directory token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, `azure` client can be authenticated by following code: + +```java +AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE); +TokenCredential credential = new DefaultAzureCredentialBuilder() + .authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint()) + .build(); +MarketplacenotificationsManager manager = MarketplacenotificationsManager + .authenticate(credential, profile); +``` + +The sample code assumes global Azure. Please change `AzureEnvironment.AZURE` variable if otherwise. + +See [Authentication][authenticate] for more options. + +## Key concepts + +See [API design][design] for general introduction on design and key concepts on Azure Management Libraries. + +## Examples + +## Troubleshooting + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/master/CONTRIBUTING.md). + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + + +[survey]: https://microsoft.qualtrics.com/jfe/form/SV_ehN0lIk2FKEBkwd?Q_CHL=DOCS +[docs]: https://azure.github.io/azure-sdk-for-java/ +[jdk]: https://docs.microsoft.com/java/azure/jdk/ +[azure_subscription]: https://azure.microsoft.com/free/ +[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/identity/azure-identity +[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core-http-netty +[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/AUTH.md +[design]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/DESIGN.md diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/pom.xml b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/pom.xml new file mode 100644 index 000000000000..fc74df34f455 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/pom.xml @@ -0,0 +1,67 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-marketplacenotifications + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for Marketplacenotifications Management + This package contains Microsoft Azure SDK for Marketplacenotifications Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Description of the new service. Package tag package-2021-03-03. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + + com.azure + azure-core + 1.15.0 + + + com.azure + azure-core-management + 1.2.1 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + + diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/MarketplacenotificationsManager.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/MarketplacenotificationsManager.java new file mode 100644 index 000000000000..a479183e573b --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/MarketplacenotificationsManager.java @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications; + +import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.AddDatePolicy; +import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.http.policy.HttpLoggingPolicy; +import com.azure.core.http.policy.HttpPipelinePolicy; +import com.azure.core.http.policy.HttpPolicyProviders; +import com.azure.core.http.policy.RequestIdPolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.profile.AzureProfile; +import com.azure.core.util.Configuration; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.marketplacenotifications.fluent.Marketplacenotifications; +import com.azure.resourcemanager.marketplacenotifications.implementation.MarketplacenotificationsBuilder; +import com.azure.resourcemanager.marketplacenotifications.implementation.OperationGroupsImpl; +import com.azure.resourcemanager.marketplacenotifications.models.OperationGroups; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Entry point to MarketplacenotificationsManager. Description of the new service. */ +public final class MarketplacenotificationsManager { + private OperationGroups operationGroups; + + private final Marketplacenotifications clientObject; + + private MarketplacenotificationsManager( + HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new MarketplacenotificationsBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .subscriptionId(profile.getSubscriptionId()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of Marketplacenotifications service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Marketplacenotifications service API instance. + */ + public static MarketplacenotificationsManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + return configure().authenticate(credential, profile); + } + + /** + * Gets a Configurable instance that can be used to create MarketplacenotificationsManager with optional + * configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new MarketplacenotificationsManager.Configurable(); + } + + /** The Configurable allowing configurations to be set. */ + public static final class Configurable { + private final ClientLogger logger = new ClientLogger(Configurable.class); + + private HttpClient httpClient; + private HttpLogOptions httpLogOptions; + private final List policies = new ArrayList<>(); + private RetryPolicy retryPolicy; + private Duration defaultPollInterval; + + private Configurable() { + } + + /** + * Sets the http client. + * + * @param httpClient the HTTP client. + * @return the configurable object itself. + */ + public Configurable withHttpClient(HttpClient httpClient) { + this.httpClient = Objects.requireNonNull(httpClient, "'httpClient' cannot be null."); + return this; + } + + /** + * Sets the logging options to the HTTP pipeline. + * + * @param httpLogOptions the HTTP log options. + * @return the configurable object itself. + */ + public Configurable withLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = Objects.requireNonNull(httpLogOptions, "'httpLogOptions' cannot be null."); + return this; + } + + /** + * Adds the pipeline policy to the HTTP pipeline. + * + * @param policy the HTTP pipeline policy. + * @return the configurable object itself. + */ + public Configurable withPolicy(HttpPipelinePolicy policy) { + this.policies.add(Objects.requireNonNull(policy, "'policy' cannot be null.")); + return this; + } + + /** + * Sets the retry policy to the HTTP pipeline. + * + * @param retryPolicy the HTTP pipeline retry policy. + * @return the configurable object itself. + */ + public Configurable withRetryPolicy(RetryPolicy retryPolicy) { + this.retryPolicy = Objects.requireNonNull(retryPolicy, "'retryPolicy' cannot be null."); + return this; + } + + /** + * Sets the default poll interval, used when service does not provide "Retry-After" header. + * + * @param defaultPollInterval the default poll interval. + * @return the configurable object itself. + */ + public Configurable withDefaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = Objects.requireNonNull(defaultPollInterval, "'retryPolicy' cannot be null."); + if (this.defaultPollInterval.isNegative()) { + throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative")); + } + return this; + } + + /** + * Creates an instance of Marketplacenotifications service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the Marketplacenotifications service API instance. + */ + public MarketplacenotificationsManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + StringBuilder userAgentBuilder = new StringBuilder(); + userAgentBuilder + .append("azsdk-java") + .append("-") + .append("com.azure.resourcemanager.marketplacenotifications") + .append("/") + .append("1.0.0-beta.1"); + if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { + userAgentBuilder + .append(" (") + .append(Configuration.getGlobalConfiguration().get("java.version")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.name")) + .append("; ") + .append(Configuration.getGlobalConfiguration().get("os.version")) + .append("; auto-generated)"); + } else { + userAgentBuilder.append(" (auto-generated)"); + } + + if (retryPolicy == null) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies.add(new UserAgentPolicy(userAgentBuilder.toString())); + policies.add(new RequestIdPolicy()); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies + .add( + new BearerTokenAuthenticationPolicy( + credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); + policies.addAll(this.policies); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new MarketplacenotificationsManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of OperationGroups. */ + public OperationGroups operationGroups() { + if (this.operationGroups == null) { + this.operationGroups = new OperationGroupsImpl(clientObject.getOperationGroups(), this); + } + return operationGroups; + } + + /** + * @return Wrapped service client Marketplacenotifications providing direct access to the underlying auto-generated + * API implementation, based on Azure REST API. + */ + public Marketplacenotifications serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/Marketplacenotifications.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/Marketplacenotifications.java new file mode 100644 index 000000000000..2b68c92efbb9 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/Marketplacenotifications.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for Marketplacenotifications class. */ +public interface Marketplacenotifications { + /** + * Gets The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + * + * @return the subscriptionId value. + */ + String getSubscriptionId(); + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * 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 OperationGroupsClient object to access its operations. + * + * @return the OperationGroupsClient object. + */ + OperationGroupsClient getOperationGroups(); +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/OperationGroupsClient.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/OperationGroupsClient.java new file mode 100644 index 000000000000..3203cbea5c2a --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/OperationGroupsClient.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.fluent; + +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; +import com.azure.resourcemanager.marketplacenotifications.fluent.models.ResultInner; + +/** An instance of this class provides access to all the operations defined in OperationGroupsClient. */ +public interface OperationGroupsClient { + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ResultInner get(String resourceGroupName); + + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response getWithResponse(String resourceGroupName, Context context); +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/models/ResultInner.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/models/ResultInner.java new file mode 100644 index 000000000000..e0c8d2981c5c --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/models/ResultInner.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Sample result definition. */ +@Fluent +public final class ResultInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResultInner.class); + + /* + * Sample property of type string + */ + @JsonProperty(value = "sampleProperty") + private String sampleProperty; + + /** + * Get the sampleProperty property: Sample property of type string. + * + * @return the sampleProperty value. + */ + public String sampleProperty() { + return this.sampleProperty; + } + + /** + * Set the sampleProperty property: Sample property of type string. + * + * @param sampleProperty the sampleProperty value to set. + * @return the ResultInner object itself. + */ + public ResultInner withSampleProperty(String sampleProperty) { + this.sampleProperty = sampleProperty; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/models/package-info.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/models/package-info.java new file mode 100644 index 000000000000..e8e703161a88 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the inner data models for Marketplacenotifications. Description of the new service. */ +package com.azure.resourcemanager.marketplacenotifications.fluent.models; diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/package-info.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/package-info.java new file mode 100644 index 000000000000..d5d1be88f865 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/fluent/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the service clients for Marketplacenotifications. Description of the new service. */ +package com.azure.resourcemanager.marketplacenotifications.fluent; diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/MarketplacenotificationsBuilder.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/MarketplacenotificationsBuilder.java new file mode 100644 index 000000000000..befd251d1324 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/MarketplacenotificationsBuilder.java @@ -0,0 +1,147 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.implementation; + +import com.azure.core.annotation.ServiceClientBuilder; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.CookiePolicy; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.serializer.SerializerFactory; +import com.azure.core.util.serializer.SerializerAdapter; +import java.time.Duration; + +/** A builder for creating a new instance of the MarketplacenotificationsImpl type. */ +@ServiceClientBuilder(serviceClients = {MarketplacenotificationsImpl.class}) +public final class MarketplacenotificationsBuilder { + /* + * The Azure subscription ID. This is a GUID-formatted string (e.g. + * 00000000-0000-0000-0000-000000000000) + */ + private String subscriptionId; + + /** + * Sets The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + * + * @param subscriptionId the subscriptionId value. + * @return the MarketplacenotificationsBuilder. + */ + public MarketplacenotificationsBuilder subscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the MarketplacenotificationsBuilder. + */ + public MarketplacenotificationsBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * The environment to connect to + */ + private AzureEnvironment environment; + + /** + * Sets The environment to connect to. + * + * @param environment the environment value. + * @return the MarketplacenotificationsBuilder. + */ + public MarketplacenotificationsBuilder environment(AzureEnvironment environment) { + this.environment = environment; + return this; + } + + /* + * The default poll interval for long-running operation + */ + private Duration defaultPollInterval; + + /** + * Sets The default poll interval for long-running operation. + * + * @param defaultPollInterval the defaultPollInterval value. + * @return the MarketplacenotificationsBuilder. + */ + public MarketplacenotificationsBuilder defaultPollInterval(Duration defaultPollInterval) { + this.defaultPollInterval = defaultPollInterval; + return this; + } + + /* + * The HTTP pipeline to send requests through + */ + private HttpPipeline pipeline; + + /** + * Sets The HTTP pipeline to send requests through. + * + * @param pipeline the pipeline value. + * @return the MarketplacenotificationsBuilder. + */ + public MarketplacenotificationsBuilder pipeline(HttpPipeline pipeline) { + this.pipeline = pipeline; + return this; + } + + /* + * The serializer to serialize an object into a string + */ + private SerializerAdapter serializerAdapter; + + /** + * Sets The serializer to serialize an object into a string. + * + * @param serializerAdapter the serializerAdapter value. + * @return the MarketplacenotificationsBuilder. + */ + public MarketplacenotificationsBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of MarketplacenotificationsImpl with the provided parameters. + * + * @return an instance of MarketplacenotificationsImpl. + */ + public MarketplacenotificationsImpl buildClient() { + if (endpoint == null) { + this.endpoint = "https://management.azure.com"; + } + if (environment == null) { + this.environment = AzureEnvironment.AZURE; + } + if (defaultPollInterval == null) { + this.defaultPollInterval = Duration.ofSeconds(30); + } + if (pipeline == null) { + this.pipeline = + new HttpPipelineBuilder() + .policies(new UserAgentPolicy(), new RetryPolicy(), new CookiePolicy()) + .build(); + } + if (serializerAdapter == null) { + this.serializerAdapter = SerializerFactory.createDefaultManagementSerializerAdapter(); + } + MarketplacenotificationsImpl client = + new MarketplacenotificationsImpl( + pipeline, serializerAdapter, defaultPollInterval, environment, subscriptionId, endpoint); + return client; + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/MarketplacenotificationsImpl.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/MarketplacenotificationsImpl.java new file mode 100644 index 000000000000..f065c057f17f --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/MarketplacenotificationsImpl.java @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.implementation; + +import com.azure.core.annotation.ServiceClient; +import com.azure.core.http.HttpHeaders; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpResponse; +import com.azure.core.http.rest.Response; +import com.azure.core.management.AzureEnvironment; +import com.azure.core.management.exception.ManagementError; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.management.polling.PollResult; +import com.azure.core.management.polling.PollerFactory; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.core.util.polling.AsyncPollResponse; +import com.azure.core.util.polling.LongRunningOperationStatus; +import com.azure.core.util.polling.PollerFlux; +import com.azure.core.util.serializer.SerializerAdapter; +import com.azure.core.util.serializer.SerializerEncoding; +import com.azure.resourcemanager.marketplacenotifications.fluent.Marketplacenotifications; +import com.azure.resourcemanager.marketplacenotifications.fluent.OperationGroupsClient; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.Map; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +/** Initializes a new instance of the MarketplacenotificationsImpl type. */ +@ServiceClient(builder = MarketplacenotificationsBuilder.class) +public final class MarketplacenotificationsImpl implements Marketplacenotifications { + private final ClientLogger logger = new ClientLogger(MarketplacenotificationsImpl.class); + + /** The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). */ + private final String subscriptionId; + + /** + * Gets The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + * + * @return the subscriptionId value. + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** 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 OperationGroupsClient object to access its operations. */ + private final OperationGroupsClient operationGroups; + + /** + * Gets the OperationGroupsClient object to access its operations. + * + * @return the OperationGroupsClient object. + */ + public OperationGroupsClient getOperationGroups() { + return this.operationGroups; + } + + /** + * Initializes an instance of Marketplacenotifications client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param defaultPollInterval The default poll interval for long-running operation. + * @param environment The Azure environment. + * @param subscriptionId The Azure subscription ID. This is a GUID-formatted string (e.g. + * 00000000-0000-0000-0000-000000000000). + * @param endpoint server parameter. + */ + MarketplacenotificationsImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String subscriptionId, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.subscriptionId = subscriptionId; + this.endpoint = endpoint; + this.operationGroups = new OperationGroupsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + for (Map.Entry entry : this.getContext().getValues().entrySet()) { + context = context.addData(entry.getKey(), entry.getValue()); + } + return context; + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult( + Mono>> activationResponse, + HttpPipeline httpPipeline, + Type pollResultType, + Type finalResultType, + Context context) { + return PollerFactory + .create( + serializerAdapter, + httpPipeline, + pollResultType, + finalResultType, + defaultPollInterval, + activationResponse, + context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = + new HttpResponseImpl( + lroError.getResponseStatusCode(), lroError.getResponseHeaders(), lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = + this + .getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException | RuntimeException ioe) { + logger.logThrowableAsWarning(ioe); + } + } + } else { + // fallback to default error message + errorMessage = "Long running operation failed."; + } + if (managementError == null) { + // fallback to default ManagementError + managementError = new ManagementError(response.getStatus().toString(), errorMessage); + } + return Mono.error(new ManagementException(errorMessage, errorResponse, managementError)); + } else { + return response.getFinalResult(); + } + } + + private static final class HttpResponseImpl extends HttpResponse { + private final int statusCode; + + private final byte[] responseBody; + + private final HttpHeaders httpHeaders; + + HttpResponseImpl(int statusCode, HttpHeaders httpHeaders, String responseBody) { + super(null); + this.statusCode = statusCode; + this.httpHeaders = httpHeaders; + this.responseBody = responseBody == null ? null : responseBody.getBytes(StandardCharsets.UTF_8); + } + + public int getStatusCode() { + return statusCode; + } + + public String getHeaderValue(String s) { + return httpHeaders.getValue(s); + } + + public HttpHeaders getHeaders() { + return httpHeaders; + } + + public Flux getBody() { + return Flux.just(ByteBuffer.wrap(responseBody)); + } + + public Mono getBodyAsByteArray() { + return Mono.just(responseBody); + } + + public Mono getBodyAsString() { + return Mono.just(new String(responseBody, StandardCharsets.UTF_8)); + } + + public Mono getBodyAsString(Charset charset) { + return Mono.just(new String(responseBody, charset)); + } + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/OperationGroupsClientImpl.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/OperationGroupsClientImpl.java new file mode 100644 index 000000000000..6f9dfdc5ca66 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/OperationGroupsClientImpl.java @@ -0,0 +1,195 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.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.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.marketplacenotifications.fluent.OperationGroupsClient; +import com.azure.resourcemanager.marketplacenotifications.fluent.models.ResultInner; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in OperationGroupsClient. */ +public final class OperationGroupsClientImpl implements OperationGroupsClient { + private final ClientLogger logger = new ClientLogger(OperationGroupsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final OperationGroupsService service; + + /** The service client containing this operation class. */ + private final MarketplacenotificationsImpl client; + + /** + * Initializes an instance of OperationGroupsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationGroupsClientImpl(MarketplacenotificationsImpl client) { + this.service = + RestProxy.create(OperationGroupsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for MarketplacenotificationsOperationGroups to be used by the proxy + * service to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "Marketplacenotificat") + private interface OperationGroupsService { + @Headers({"Content-Type: application/json"}) + @Get( + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers" + + "/Microsoft.MarketplaceNotifications/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> get( + @HostParam("$host") String endpoint, + @PathParam("subscriptionId") String subscriptionId, + @PathParam("resourceGroupName") String resourceGroupName, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .get( + this.client.getEndpoint(), + this.client.getSubscriptionId(), + resourceGroupName, + accept, + context)) + .contextWrite(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()).readOnly())); + } + + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> getWithResponseAsync(String resourceGroupName, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (this.client.getSubscriptionId() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getSubscriptionId() is required and cannot be null.")); + } + if (resourceGroupName == null) { + return Mono + .error(new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .get(this.client.getEndpoint(), this.client.getSubscriptionId(), resourceGroupName, accept, context); + } + + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono getAsync(String resourceGroupName) { + return getWithResponseAsync(resourceGroupName) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResultInner get(String resourceGroupName) { + return getAsync(resourceGroupName).block(); + } + + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getWithResponse(String resourceGroupName, Context context) { + return getWithResponseAsync(resourceGroupName, context).block(); + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/OperationGroupsImpl.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/OperationGroupsImpl.java new file mode 100644 index 000000000000..46e7afc7725a --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/OperationGroupsImpl.java @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.implementation; + +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.SimpleResponse; +import com.azure.core.util.Context; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.marketplacenotifications.fluent.OperationGroupsClient; +import com.azure.resourcemanager.marketplacenotifications.fluent.models.ResultInner; +import com.azure.resourcemanager.marketplacenotifications.models.OperationGroups; +import com.azure.resourcemanager.marketplacenotifications.models.Result; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class OperationGroupsImpl implements OperationGroups { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationGroupsImpl.class); + + private final OperationGroupsClient innerClient; + + private final com.azure.resourcemanager.marketplacenotifications.MarketplacenotificationsManager serviceManager; + + public OperationGroupsImpl( + OperationGroupsClient innerClient, + com.azure.resourcemanager.marketplacenotifications.MarketplacenotificationsManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public Result get(String resourceGroupName) { + ResultInner inner = this.serviceClient().get(resourceGroupName); + if (inner != null) { + return new ResultImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response getWithResponse(String resourceGroupName, Context context) { + Response inner = this.serviceClient().getWithResponse(resourceGroupName, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ResultImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + private OperationGroupsClient serviceClient() { + return this.innerClient; + } + + private com.azure.resourcemanager.marketplacenotifications.MarketplacenotificationsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/ResultImpl.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/ResultImpl.java new file mode 100644 index 000000000000..f5568b9761aa --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/ResultImpl.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.implementation; + +import com.azure.resourcemanager.marketplacenotifications.fluent.models.ResultInner; +import com.azure.resourcemanager.marketplacenotifications.models.Result; + +public final class ResultImpl implements Result { + private ResultInner innerObject; + + private final com.azure.resourcemanager.marketplacenotifications.MarketplacenotificationsManager serviceManager; + + ResultImpl( + ResultInner innerObject, + com.azure.resourcemanager.marketplacenotifications.MarketplacenotificationsManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String sampleProperty() { + return this.innerModel().sampleProperty(); + } + + public ResultInner innerModel() { + return this.innerObject; + } + + private com.azure.resourcemanager.marketplacenotifications.MarketplacenotificationsManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/Utils.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/Utils.java new file mode 100644 index 000000000000..f117aa13d50e --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/Utils.java @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.implementation; + +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.util.CoreUtils; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import reactor.core.publisher.Flux; + +final class Utils { + static String getValueFromIdByName(String id, String name) { + if (id == null) { + return null; + } + Iterator itr = Arrays.stream(id.split("/")).iterator(); + while (itr.hasNext()) { + String part = itr.next(); + if (part != null && !part.trim().isEmpty()) { + if (part.equalsIgnoreCase(name)) { + if (itr.hasNext()) { + return itr.next(); + } else { + return null; + } + } + } + } + return null; + } + + static String getValueFromIdByParameterName(String id, String pathTemplate, String parameterName) { + if (id == null || pathTemplate == null) { + return null; + } + String parameterNameParentheses = "{" + parameterName + "}"; + List idSegmentsReverted = Arrays.asList(id.split("/")); + List pathSegments = Arrays.asList(pathTemplate.split("/")); + Collections.reverse(idSegmentsReverted); + Iterator idItrReverted = idSegmentsReverted.iterator(); + int pathIndex = pathSegments.size(); + while (idItrReverted.hasNext() && pathIndex > 0) { + String idSegment = idItrReverted.next(); + String pathSegment = pathSegments.get(--pathIndex); + if (!CoreUtils.isNullOrEmpty(idSegment) && !CoreUtils.isNullOrEmpty(pathSegment)) { + if (pathSegment.equalsIgnoreCase(parameterNameParentheses)) { + if (pathIndex == 0 || (pathIndex == 1 && pathSegments.get(0).isEmpty())) { + List segments = new ArrayList<>(); + segments.add(idSegment); + idItrReverted.forEachRemaining(segments::add); + Collections.reverse(segments); + if (segments.size() > 0 && segments.get(0).isEmpty()) { + segments.remove(0); + } + return String.join("/", segments); + } else { + return idSegment; + } + } + } + } + return null; + } + + static PagedIterable mapPage(PagedIterable pageIterable, Function mapper) { + return new PagedIterableImpl(pageIterable, mapper); + } + + private static final class PagedIterableImpl extends PagedIterable { + + private final PagedIterable pagedIterable; + private final Function mapper; + private final Function, PagedResponse> pageMapper; + + private PagedIterableImpl(PagedIterable pagedIterable, Function mapper) { + super( + PagedFlux + .create( + () -> + (continuationToken, pageSize) -> + Flux.fromStream(pagedIterable.streamByPage().map(getPageMapper(mapper))))); + this.pagedIterable = pagedIterable; + this.mapper = mapper; + this.pageMapper = getPageMapper(mapper); + } + + private static Function, PagedResponse> getPageMapper(Function mapper) { + return page -> + new PagedResponseBase( + page.getRequest(), + page.getStatusCode(), + page.getHeaders(), + page.getElements().stream().map(mapper).collect(Collectors.toList()), + page.getContinuationToken(), + null); + } + + @Override + public Stream stream() { + return pagedIterable.stream().map(mapper); + } + + @Override + public Stream> streamByPage() { + return pagedIterable.streamByPage().map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken) { + return pagedIterable.streamByPage(continuationToken).map(pageMapper); + } + + @Override + public Stream> streamByPage(int preferredPageSize) { + return pagedIterable.streamByPage(preferredPageSize).map(pageMapper); + } + + @Override + public Stream> streamByPage(String continuationToken, int preferredPageSize) { + return pagedIterable.streamByPage(continuationToken, preferredPageSize).map(pageMapper); + } + + @Override + public Iterator iterator() { + return new IteratorImpl(pagedIterable.iterator(), mapper); + } + + @Override + public Iterable> iterableByPage() { + return new IterableImpl, PagedResponse>(pagedIterable.iterableByPage(), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken), pageMapper); + } + + @Override + public Iterable> iterableByPage(int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(preferredPageSize), pageMapper); + } + + @Override + public Iterable> iterableByPage(String continuationToken, int preferredPageSize) { + return new IterableImpl, PagedResponse>( + pagedIterable.iterableByPage(continuationToken, preferredPageSize), pageMapper); + } + } + + private static final class IteratorImpl implements Iterator { + + private final Iterator iterator; + private final Function mapper; + + private IteratorImpl(Iterator iterator, Function mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public S next() { + return mapper.apply(iterator.next()); + } + + @Override + public void remove() { + iterator.remove(); + } + } + + private static final class IterableImpl implements Iterable { + + private final Iterable iterable; + private final Function mapper; + + private IterableImpl(Iterable iterable, Function mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + @Override + public Iterator iterator() { + return new IteratorImpl(iterable.iterator(), mapper); + } + } +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/package-info.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/package-info.java new file mode 100644 index 000000000000..ceaa6f6800f6 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/implementation/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the implementations for Marketplacenotifications. Description of the new service. */ +package com.azure.resourcemanager.marketplacenotifications.implementation; diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/OperationGroups.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/OperationGroups.java new file mode 100644 index 000000000000..5f5bb79dc7a5 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/OperationGroups.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of OperationGroups. */ +public interface OperationGroups { + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + Result get(String resourceGroupName); + + /** + * This is a sample get operation, please see guidelines in azure-rest-api-specs repository for more info. + * + * @param resourceGroupName The name of the resource group. + * @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 sample result definition. + */ + Response getWithResponse(String resourceGroupName, Context context); +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/Result.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/Result.java new file mode 100644 index 000000000000..4185f903131a --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/Result.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.marketplacenotifications.models; + +import com.azure.resourcemanager.marketplacenotifications.fluent.models.ResultInner; + +/** An immutable client-side representation of Result. */ +public interface Result { + /** + * Gets the sampleProperty property: Sample property of type string. + * + * @return the sampleProperty value. + */ + String sampleProperty(); + + /** + * Gets the inner com.azure.resourcemanager.marketplacenotifications.fluent.models.ResultInner object. + * + * @return the inner object. + */ + ResultInner innerModel(); +} diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/package-info.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/package-info.java new file mode 100644 index 000000000000..abe27e1bc036 --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/models/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the data models for Marketplacenotifications. Description of the new service. */ +package com.azure.resourcemanager.marketplacenotifications.models; diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/package-info.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/package-info.java new file mode 100644 index 000000000000..0597afb66f8c --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/com/azure/resourcemanager/marketplacenotifications/package-info.java @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** Package containing the classes for Marketplacenotifications. Description of the new service. */ +package com.azure.resourcemanager.marketplacenotifications; diff --git a/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/module-info.java b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/module-info.java new file mode 100644 index 000000000000..b487f7907e1e --- /dev/null +++ b/sdk/marketplacenotifications/azure-resourcemanager-marketplacenotifications/src/main/java/module-info.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +module com.azure.resourcemanager.marketplacenotifications { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.marketplacenotifications; + exports com.azure.resourcemanager.marketplacenotifications.fluent; + exports com.azure.resourcemanager.marketplacenotifications.fluent.models; + exports com.azure.resourcemanager.marketplacenotifications.models; + + opens com.azure.resourcemanager.marketplacenotifications.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.marketplacenotifications.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/marketplacenotifications/ci.yml b/sdk/marketplacenotifications/ci.yml new file mode 100644 index 000000000000..340ab1dd192b --- /dev/null +++ b/sdk/marketplacenotifications/ci.yml @@ -0,0 +1,33 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - main + - hotfix/* + - release/* + paths: + include: + - sdk/marketplacenotifications/ + +pr: + branches: + include: + - master + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/marketplacenotifications/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: marketplacenotifications + Artifacts: + - name: azure-resourcemanager-marketplacenotifications + groupId: com.azure.resourcemanager + safeName: azureresourcemanagermarketplacenotifications diff --git a/sdk/marketplacenotifications/pom.xml b/sdk/marketplacenotifications/pom.xml new file mode 100644 index 000000000000..a8cce65ac657 --- /dev/null +++ b/sdk/marketplacenotifications/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + com.azure + azure-marketplacenotifications-service + pom + 1.0.0 + + + + coverage + + + + + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + + report-aggregate + verify + + report-aggregate + + + ${project.reporting.outputDirectory}/test-coverage + + + + + + + + + default + + true + + + azure-resourcemanager-marketplacenotifications + + + +