diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index eda21ff82375..6d96d39f43ae 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -187,6 +187,7 @@ com.azure.resourcemanager:azure-resourcemanager-recoveryservices;1.0.0-beta.1;1. com.azure.resourcemanager:azure-resourcemanager-kusto;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-loganalytics;1.0.0-beta.1;1.0.0-beta.2 com.azure.resourcemanager:azure-resourcemanager-eventgrid;1.0.0-beta.1;1.0.0-beta.2 +com.azure.resourcemanager:azure-resourcemanager-resourcegraph;1.0.0-beta.1;1.0.0-beta.1 com.microsoft:microsoft-opentelemetry-exporter-azuremonitor;1.0.0-beta.1;1.0.0-beta.2 diff --git a/pom.xml b/pom.xml index b80dac967d8f..5e2e713164f0 100644 --- a/pom.xml +++ b/pom.xml @@ -37,6 +37,7 @@ sdk/postgresql sdk/recoveryservices sdk/relay + sdk/resourcegraph sdk/resourcemanager sdk/schemaregistry sdk/search diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/CHANGELOG.md b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/CHANGELOG.md new file mode 100644 index 000000000000..07c9af76eea8 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0-beta.1 (2021-01-04) + +- Azure Resource Manager ResourceGraph client library for Java. This package contains Microsoft Azure SDK for ResourceGraph Management SDK. Azure Resource Graph API Reference. Package tag package-preview-2020-04. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). \ No newline at end of file diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/README.md b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/README.md new file mode 100644 index 000000000000..41801e9ce4e6 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/README.md @@ -0,0 +1,83 @@ +# Azure Resource Manager ResourceGraph client library for Java + +Azure Resource Manager ResourceGraph client library for Java. + +This package contains Microsoft Azure SDK for ResourceGraph Management SDK. Azure Resource Graph API Reference. Package tag package-preview-2020-04. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). + +## 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-resourcegraph;current}) +```xml + + com.azure.resourcemanager + azure-resourcemanager-resourcegraph + 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(); +ResourceGraphManager manager = ResourceGraphManager + .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 + + +[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/resourcegraph/azure-resourcemanager-resourcegraph/pom.xml b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/pom.xml new file mode 100644 index 000000000000..ca36e27f19a3 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/pom.xml @@ -0,0 +1,62 @@ + + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + + + com.azure.resourcemanager + azure-resourcemanager-resourcegraph + 1.0.0-beta.1 + jar + + Microsoft Azure SDK for ResourceGraph Management + This package contains Microsoft Azure SDK for ResourceGraph Management SDK. Azure Resource Graph API Reference. Package tag package-preview-2020-04. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt + 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-management + 1.0.0 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + + diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/ResourceGraphManager.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/ResourceGraphManager.java new file mode 100644 index 000000000000..6b6b85e215e3 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/ResourceGraphManager.java @@ -0,0 +1,211 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph; + +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.resourcegraph.fluent.ResourceGraphClient; +import com.azure.resourcemanager.resourcegraph.implementation.OperationsImpl; +import com.azure.resourcemanager.resourcegraph.implementation.ResourceGraphClientBuilder; +import com.azure.resourcemanager.resourcegraph.implementation.ResourceProvidersImpl; +import com.azure.resourcemanager.resourcegraph.models.Operations; +import com.azure.resourcemanager.resourcegraph.models.ResourceProviders; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Entry point to ResourceGraphManager. Azure Resource Graph API Reference. */ +public final class ResourceGraphManager { + private ResourceProviders resourceProviders; + + private Operations operations; + + private final ResourceGraphClient clientObject; + + private ResourceGraphManager(HttpPipeline httpPipeline, AzureProfile profile, Duration defaultPollInterval) { + Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + this.clientObject = + new ResourceGraphClientBuilder() + .pipeline(httpPipeline) + .endpoint(profile.getEnvironment().getResourceManagerEndpoint()) + .defaultPollInterval(defaultPollInterval) + .buildClient(); + } + + /** + * Creates an instance of ResourceGraph service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ResourceGraph service API instance. + */ + public static ResourceGraphManager 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 ResourceGraphManager with optional configuration. + * + * @return the Configurable instance allowing configurations. + */ + public static Configurable configure() { + return new ResourceGraphManager.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 ResourceGraph service API entry point. + * + * @param credential the credential to use. + * @param profile the Azure profile for client. + * @return the ResourceGraph service API instance. + */ + public ResourceGraphManager authenticate(TokenCredential credential, AzureProfile profile) { + Objects.requireNonNull(credential, "'credential' cannot be null."); + Objects.requireNonNull(profile, "'profile' cannot be null."); + + if (retryPolicy == null) { + retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); + } + List policies = new ArrayList<>(); + policies + .add( + new UserAgentPolicy( + null, + "com.azure.resourcemanager.resourcegraph", + "1.0.0-beta.1", + Configuration.getGlobalConfiguration())); + policies.add(new RequestIdPolicy()); + HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy); + policies.add(new AddDatePolicy()); + policies + .add( + new BearerTokenAuthenticationPolicy( + credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); + HttpPolicyProviders.addAfterRetryPolicies(policies); + policies.add(new HttpLoggingPolicy(httpLogOptions)); + HttpPipeline httpPipeline = + new HttpPipelineBuilder() + .httpClient(httpClient) + .policies(policies.toArray(new HttpPipelinePolicy[0])) + .build(); + return new ResourceGraphManager(httpPipeline, profile, defaultPollInterval); + } + } + + /** @return Resource collection API of ResourceProviders. */ + public ResourceProviders resourceProviders() { + if (this.resourceProviders == null) { + this.resourceProviders = new ResourceProvidersImpl(clientObject.getResourceProviders(), this); + } + return resourceProviders; + } + + /** @return Resource collection API of Operations. */ + public Operations operations() { + if (this.operations == null) { + this.operations = new OperationsImpl(clientObject.getOperations(), this); + } + return operations; + } + + /** + * @return Wrapped service client ResourceGraphClient providing direct access to the underlying auto-generated API + * implementation, based on Azure REST API. + */ + public ResourceGraphClient serviceClient() { + return this.clientObject; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/OperationsClient.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/OperationsClient.java new file mode 100644 index 000000000000..3d46ac606fcb --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/OperationsClient.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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.resourcegraph.fluent.models.OperationInner; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public interface OperationsClient { + /** + * Lists all of the available REST API operations. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(); + + /** + * Lists all of the available REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + PagedIterable list(Context context); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/ResourceGraphClient.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/ResourceGraphClient.java new file mode 100644 index 000000000000..16412a3b5883 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/ResourceGraphClient.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.fluent; + +import com.azure.core.http.HttpPipeline; +import java.time.Duration; + +/** The interface for ResourceGraphClient class. */ +public interface ResourceGraphClient { + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + String getEndpoint(); + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + String getApiVersion(); + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + HttpPipeline getHttpPipeline(); + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + Duration getDefaultPollInterval(); + + /** + * Gets the ResourceProvidersClient object to access its operations. + * + * @return the ResourceProvidersClient object. + */ + ResourceProvidersClient getResourceProviders(); + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + OperationsClient getOperations(); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/ResourceProvidersClient.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/ResourceProvidersClient.java new file mode 100644 index 000000000000..f867b4dd9462 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/ResourceProvidersClient.java @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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.resourcegraph.fluent.models.QueryResponseInner; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeDataInner; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeListInner; +import com.azure.resourcemanager.resourcegraph.models.QueryRequest; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeDetailsRequestParameters; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangesRequestParameters; + +/** An instance of this class provides access to all the operations defined in ResourceProvidersClient. */ +public interface ResourceProvidersClient { + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + QueryResponseInner resources(QueryRequest query); + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response resourcesWithResponse(QueryRequest query, Context context); + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ResourceChangeListInner resourceChanges(ResourceChangesRequestParameters parameters); + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response resourceChangesWithResponse( + ResourceChangesRequestParameters parameters, Context context); + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + ResourceChangeDataInner resourceChangeDetails(ResourceChangeDetailsRequestParameters parameters); + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + Response resourceChangeDetailsWithResponse( + ResourceChangeDetailsRequestParameters parameters, Context context); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/OperationInner.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/OperationInner.java new file mode 100644 index 000000000000..b7b050ec7e8d --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/OperationInner.java @@ -0,0 +1,106 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.resourcegraph.models.OperationDisplay; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** Resource Graph REST API operation definition. */ +@Fluent +public final class OperationInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationInner.class); + + /* + * Operation name: {provider}/{resource}/{operation} + */ + @JsonProperty(value = "name") + private String name; + + /* + * Display metadata associated with the operation. + */ + @JsonProperty(value = "display") + private OperationDisplay display; + + /* + * The origin of operations. + */ + @JsonProperty(value = "origin") + private String origin; + + /** + * Get the name property: Operation name: {provider}/{resource}/{operation}. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Operation name: {provider}/{resource}/{operation}. + * + * @param name the name value to set. + * @return the OperationInner object itself. + */ + public OperationInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the display property: Display metadata associated with the operation. + * + * @return the display value. + */ + public OperationDisplay display() { + return this.display; + } + + /** + * Set the display property: Display metadata associated with the operation. + * + * @param display the display value to set. + * @return the OperationInner object itself. + */ + public OperationInner withDisplay(OperationDisplay display) { + this.display = display; + return this; + } + + /** + * Get the origin property: The origin of operations. + * + * @return the origin value. + */ + public String origin() { + return this.origin; + } + + /** + * Set the origin property: The origin of operations. + * + * @param origin the origin value to set. + * @return the OperationInner object itself. + */ + public OperationInner withOrigin(String origin) { + this.origin = origin; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (display() != null) { + display().validate(); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/QueryResponseInner.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/QueryResponseInner.java new file mode 100644 index 000000000000..83fa86a1ccad --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/QueryResponseInner.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.resourcegraph.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.resourcegraph.models.Facet; +import com.azure.resourcemanager.resourcegraph.models.ResultTruncated; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Query result. */ +@Fluent +public final class QueryResponseInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QueryResponseInner.class); + + /* + * Number of total records matching the query. + */ + @JsonProperty(value = "totalRecords", required = true) + private long totalRecords; + + /* + * Number of records returned in the current response. In the case of + * paging, this is the number of records in the current page. + */ + @JsonProperty(value = "count", required = true) + private long count; + + /* + * Indicates whether the query results are truncated. + */ + @JsonProperty(value = "resultTruncated", required = true) + private ResultTruncated resultTruncated; + + /* + * When present, the value can be passed to a subsequent query call + * (together with the same query and subscriptions used in the current + * request) to retrieve the next page of data. + */ + @JsonProperty(value = "$skipToken") + private String skipToken; + + /* + * Query output in tabular format. + */ + @JsonProperty(value = "data", required = true) + private Object data; + + /* + * Query facets. + */ + @JsonProperty(value = "facets") + private List facets; + + /** + * Get the totalRecords property: Number of total records matching the query. + * + * @return the totalRecords value. + */ + public long totalRecords() { + return this.totalRecords; + } + + /** + * Set the totalRecords property: Number of total records matching the query. + * + * @param totalRecords the totalRecords value to set. + * @return the QueryResponseInner object itself. + */ + public QueryResponseInner withTotalRecords(long totalRecords) { + this.totalRecords = totalRecords; + return this; + } + + /** + * Get the count property: Number of records returned in the current response. In the case of paging, this is the + * number of records in the current page. + * + * @return the count value. + */ + public long count() { + return this.count; + } + + /** + * Set the count property: Number of records returned in the current response. In the case of paging, this is the + * number of records in the current page. + * + * @param count the count value to set. + * @return the QueryResponseInner object itself. + */ + public QueryResponseInner withCount(long count) { + this.count = count; + return this; + } + + /** + * Get the resultTruncated property: Indicates whether the query results are truncated. + * + * @return the resultTruncated value. + */ + public ResultTruncated resultTruncated() { + return this.resultTruncated; + } + + /** + * Set the resultTruncated property: Indicates whether the query results are truncated. + * + * @param resultTruncated the resultTruncated value to set. + * @return the QueryResponseInner object itself. + */ + public QueryResponseInner withResultTruncated(ResultTruncated resultTruncated) { + this.resultTruncated = resultTruncated; + return this; + } + + /** + * Get the skipToken property: When present, the value can be passed to a subsequent query call (together with the + * same query and subscriptions used in the current request) to retrieve the next page of data. + * + * @return the skipToken value. + */ + public String skipToken() { + return this.skipToken; + } + + /** + * Set the skipToken property: When present, the value can be passed to a subsequent query call (together with the + * same query and subscriptions used in the current request) to retrieve the next page of data. + * + * @param skipToken the skipToken value to set. + * @return the QueryResponseInner object itself. + */ + public QueryResponseInner withSkipToken(String skipToken) { + this.skipToken = skipToken; + return this; + } + + /** + * Get the data property: Query output in tabular format. + * + * @return the data value. + */ + public Object data() { + return this.data; + } + + /** + * Set the data property: Query output in tabular format. + * + * @param data the data value to set. + * @return the QueryResponseInner object itself. + */ + public QueryResponseInner withData(Object data) { + this.data = data; + return this; + } + + /** + * Get the facets property: Query facets. + * + * @return the facets value. + */ + public List facets() { + return this.facets; + } + + /** + * Set the facets property: Query facets. + * + * @param facets the facets value to set. + * @return the QueryResponseInner object itself. + */ + public QueryResponseInner withFacets(List facets) { + this.facets = facets; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (resultTruncated() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property resultTruncated in model QueryResponseInner")); + } + if (data() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property data in model QueryResponseInner")); + } + if (facets() != null) { + facets().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/ResourceChangeDataInner.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/ResourceChangeDataInner.java new file mode 100644 index 000000000000..94462586eadc --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/ResourceChangeDataInner.java @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.fluent.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.resourcegraph.models.ChangeType; +import com.azure.resourcemanager.resourcegraph.models.ResourcePropertyChange; +import com.azure.resourcemanager.resourcegraph.models.ResourceSnapshotData; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Data on a specific change, represented by a pair of before and after resource snapshots. */ +@Fluent +public final class ResourceChangeDataInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceChangeDataInner.class); + + /* + * The change ID. Valid and unique within the specified resource only. + */ + @JsonProperty(value = "changeId", required = true) + private String changeId; + + /* + * The snapshot before the change. + */ + @JsonProperty(value = "beforeSnapshot", required = true) + private ResourceSnapshotData beforeSnapshot; + + /* + * The snapshot after the change. + */ + @JsonProperty(value = "afterSnapshot", required = true) + private ResourceSnapshotData afterSnapshot; + + /* + * The change type for snapshot. PropertyChanges will be provided in case + * of Update change type + */ + @JsonProperty(value = "changeType") + private ChangeType changeType; + + /* + * An array of resource property change + */ + @JsonProperty(value = "propertyChanges") + private List propertyChanges; + + /** + * Get the changeId property: The change ID. Valid and unique within the specified resource only. + * + * @return the changeId value. + */ + public String changeId() { + return this.changeId; + } + + /** + * Set the changeId property: The change ID. Valid and unique within the specified resource only. + * + * @param changeId the changeId value to set. + * @return the ResourceChangeDataInner object itself. + */ + public ResourceChangeDataInner withChangeId(String changeId) { + this.changeId = changeId; + return this; + } + + /** + * Get the beforeSnapshot property: The snapshot before the change. + * + * @return the beforeSnapshot value. + */ + public ResourceSnapshotData beforeSnapshot() { + return this.beforeSnapshot; + } + + /** + * Set the beforeSnapshot property: The snapshot before the change. + * + * @param beforeSnapshot the beforeSnapshot value to set. + * @return the ResourceChangeDataInner object itself. + */ + public ResourceChangeDataInner withBeforeSnapshot(ResourceSnapshotData beforeSnapshot) { + this.beforeSnapshot = beforeSnapshot; + return this; + } + + /** + * Get the afterSnapshot property: The snapshot after the change. + * + * @return the afterSnapshot value. + */ + public ResourceSnapshotData afterSnapshot() { + return this.afterSnapshot; + } + + /** + * Set the afterSnapshot property: The snapshot after the change. + * + * @param afterSnapshot the afterSnapshot value to set. + * @return the ResourceChangeDataInner object itself. + */ + public ResourceChangeDataInner withAfterSnapshot(ResourceSnapshotData afterSnapshot) { + this.afterSnapshot = afterSnapshot; + return this; + } + + /** + * Get the changeType property: The change type for snapshot. PropertyChanges will be provided in case of Update + * change type. + * + * @return the changeType value. + */ + public ChangeType changeType() { + return this.changeType; + } + + /** + * Set the changeType property: The change type for snapshot. PropertyChanges will be provided in case of Update + * change type. + * + * @param changeType the changeType value to set. + * @return the ResourceChangeDataInner object itself. + */ + public ResourceChangeDataInner withChangeType(ChangeType changeType) { + this.changeType = changeType; + return this; + } + + /** + * Get the propertyChanges property: An array of resource property change. + * + * @return the propertyChanges value. + */ + public List propertyChanges() { + return this.propertyChanges; + } + + /** + * Set the propertyChanges property: An array of resource property change. + * + * @param propertyChanges the propertyChanges value to set. + * @return the ResourceChangeDataInner object itself. + */ + public ResourceChangeDataInner withPropertyChanges(List propertyChanges) { + this.propertyChanges = propertyChanges; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (changeId() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property changeId in model ResourceChangeDataInner")); + } + if (beforeSnapshot() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property beforeSnapshot in model ResourceChangeDataInner")); + } else { + beforeSnapshot().validate(); + } + if (afterSnapshot() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property afterSnapshot in model ResourceChangeDataInner")); + } else { + afterSnapshot().validate(); + } + if (propertyChanges() != null) { + propertyChanges().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/ResourceChangeListInner.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/ResourceChangeListInner.java new file mode 100644 index 000000000000..51a35d029c48 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/ResourceChangeListInner.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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; +import java.util.List; + +/** A list of changes associated with a resource over a specific time interval. */ +@Fluent +public final class ResourceChangeListInner { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceChangeListInner.class); + + /* + * The pageable value returned by the operation, i.e. a list of changes to + * the resource. + * + * - The list is ordered from the most recent changes to the least recent + * changes. + * - This list will be empty if there were no changes during the requested + * interval. + * - The `Before` snapshot timestamp value of the oldest change can be + * outside of the specified time interval. + */ + @JsonProperty(value = "changes") + private List changes; + + /* + * Skip token that encodes the skip information while executing the current + * request + */ + @JsonProperty(value = "$skipToken") + private Object skipToken; + + /** + * Get the changes property: The pageable value returned by the operation, i.e. a list of changes to the resource. + * + *

- The list is ordered from the most recent changes to the least recent changes. - This list will be empty if + * there were no changes during the requested interval. - The `Before` snapshot timestamp value of the oldest change + * can be outside of the specified time interval. + * + * @return the changes value. + */ + public List changes() { + return this.changes; + } + + /** + * Set the changes property: The pageable value returned by the operation, i.e. a list of changes to the resource. + * + *

- The list is ordered from the most recent changes to the least recent changes. - This list will be empty if + * there were no changes during the requested interval. - The `Before` snapshot timestamp value of the oldest change + * can be outside of the specified time interval. + * + * @param changes the changes value to set. + * @return the ResourceChangeListInner object itself. + */ + public ResourceChangeListInner withChanges(List changes) { + this.changes = changes; + return this; + } + + /** + * Get the skipToken property: Skip token that encodes the skip information while executing the current request. + * + * @return the skipToken value. + */ + public Object skipToken() { + return this.skipToken; + } + + /** + * Set the skipToken property: Skip token that encodes the skip information while executing the current request. + * + * @param skipToken the skipToken value to set. + * @return the ResourceChangeListInner object itself. + */ + public ResourceChangeListInner withSkipToken(Object skipToken) { + this.skipToken = skipToken; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (changes() != null) { + changes().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/package-info.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/models/package-info.java new file mode 100644 index 000000000000..5410d51bcbe0 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/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 ResourceGraphClient. Azure Resource Graph API Reference. */ +package com.azure.resourcemanager.resourcegraph.fluent.models; diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/package-info.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/fluent/package-info.java new file mode 100644 index 000000000000..cefdb4e58109 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/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 ResourceGraphClient. Azure Resource Graph API Reference. */ +package com.azure.resourcemanager.resourcegraph.fluent; diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationImpl.java new file mode 100644 index 000000000000..2fb920f4adeb --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationImpl.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.implementation; + +import com.azure.resourcemanager.resourcegraph.ResourceGraphManager; +import com.azure.resourcemanager.resourcegraph.fluent.models.OperationInner; +import com.azure.resourcemanager.resourcegraph.models.Operation; +import com.azure.resourcemanager.resourcegraph.models.OperationDisplay; + +public final class OperationImpl implements Operation { + private OperationInner innerObject; + + private final ResourceGraphManager serviceManager; + + OperationImpl(OperationInner innerObject, ResourceGraphManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String name() { + return this.innerModel().name(); + } + + public OperationDisplay display() { + return this.innerModel().display(); + } + + public String origin() { + return this.innerModel().origin(); + } + + public OperationInner innerModel() { + return this.innerObject; + } + + private ResourceGraphManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationsClientImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationsClientImpl.java new file mode 100644 index 000000000000..715a5a11daf4 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationsClientImpl.java @@ -0,0 +1,176 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.PagedFlux; +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.http.rest.PagedResponse; +import com.azure.core.http.rest.PagedResponseBase; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.resourcegraph.fluent.OperationsClient; +import com.azure.resourcemanager.resourcegraph.fluent.models.OperationInner; +import com.azure.resourcemanager.resourcegraph.models.OperationListResult; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in OperationsClient. */ +public final class OperationsClientImpl implements OperationsClient { + private final ClientLogger logger = new ClientLogger(OperationsClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final OperationsService service; + + /** The service client containing this operation class. */ + private final ResourceGraphClientImpl client; + + /** + * Initializes an instance of OperationsClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsClientImpl(ResourceGraphClientImpl client) { + this.service = + RestProxy.create(OperationsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ResourceGraphClientOperations to be used by the proxy service to + * perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "ResourceGraphClientO") + private interface OperationsService { + @Headers({"Content-Type: application/json"}) + @Get("/providers/Microsoft.ResourceGraph/operations") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> list( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Lists all of the available REST API operations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync() { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> service.list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context)) + .>map( + res -> + new PagedResponseBase<>( + res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Lists all of the available REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> listSinglePageAsync(Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .list(this.client.getEndpoint(), this.client.getApiVersion(), accept, context) + .map( + res -> + new PagedResponseBase<>( + res.getRequest(), res.getStatusCode(), res.getHeaders(), res.getValue().value(), null, null)); + } + + /** + * Lists all of the available REST API operations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync() { + return new PagedFlux<>(() -> listSinglePageAsync()); + } + + /** + * Lists all of the available REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + private PagedFlux listAsync(Context context) { + return new PagedFlux<>(() -> listSinglePageAsync(context)); + } + + /** + * Lists all of the available REST API operations. + * + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list() { + return new PagedIterable<>(listAsync()); + } + + /** + * Lists all of the available REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable list(Context context) { + return new PagedIterable<>(listAsync(context)); + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationsImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationsImpl.java new file mode 100644 index 000000000000..c94b82433a36 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/OperationsImpl.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.resourcegraph.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.resourcegraph.ResourceGraphManager; +import com.azure.resourcemanager.resourcegraph.fluent.OperationsClient; +import com.azure.resourcemanager.resourcegraph.fluent.models.OperationInner; +import com.azure.resourcemanager.resourcegraph.models.Operation; +import com.azure.resourcemanager.resourcegraph.models.Operations; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class OperationsImpl implements Operations { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationsImpl.class); + + private final OperationsClient innerClient; + + private final ResourceGraphManager serviceManager; + + public OperationsImpl(OperationsClient innerClient, ResourceGraphManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public PagedIterable list() { + PagedIterable inner = this.serviceClient().list(); + return inner.mapPage(inner1 -> new OperationImpl(inner1, this.manager())); + } + + public PagedIterable list(Context context) { + PagedIterable inner = this.serviceClient().list(context); + return inner.mapPage(inner1 -> new OperationImpl(inner1, this.manager())); + } + + private OperationsClient serviceClient() { + return this.innerClient; + } + + private ResourceGraphManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/QueryResponseImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/QueryResponseImpl.java new file mode 100644 index 000000000000..d5590d075815 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/QueryResponseImpl.java @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.implementation; + +import com.azure.resourcemanager.resourcegraph.ResourceGraphManager; +import com.azure.resourcemanager.resourcegraph.fluent.models.QueryResponseInner; +import com.azure.resourcemanager.resourcegraph.models.Facet; +import com.azure.resourcemanager.resourcegraph.models.QueryResponse; +import com.azure.resourcemanager.resourcegraph.models.ResultTruncated; +import java.util.Collections; +import java.util.List; + +public final class QueryResponseImpl implements QueryResponse { + private QueryResponseInner innerObject; + + private final ResourceGraphManager serviceManager; + + QueryResponseImpl(QueryResponseInner innerObject, ResourceGraphManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public long totalRecords() { + return this.innerModel().totalRecords(); + } + + public long count() { + return this.innerModel().count(); + } + + public ResultTruncated resultTruncated() { + return this.innerModel().resultTruncated(); + } + + public String skipToken() { + return this.innerModel().skipToken(); + } + + public Object data() { + return this.innerModel().data(); + } + + public List facets() { + List inner = this.innerModel().facets(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public QueryResponseInner innerModel() { + return this.innerObject; + } + + private ResourceGraphManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceChangeDataImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceChangeDataImpl.java new file mode 100644 index 000000000000..3fb317d47bf5 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceChangeDataImpl.java @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.implementation; + +import com.azure.resourcemanager.resourcegraph.ResourceGraphManager; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeDataInner; +import com.azure.resourcemanager.resourcegraph.models.ChangeType; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeData; +import com.azure.resourcemanager.resourcegraph.models.ResourcePropertyChange; +import com.azure.resourcemanager.resourcegraph.models.ResourceSnapshotData; +import java.util.Collections; +import java.util.List; + +public final class ResourceChangeDataImpl implements ResourceChangeData { + private ResourceChangeDataInner innerObject; + + private final ResourceGraphManager serviceManager; + + ResourceChangeDataImpl(ResourceChangeDataInner innerObject, ResourceGraphManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public String changeId() { + return this.innerModel().changeId(); + } + + public ResourceSnapshotData beforeSnapshot() { + return this.innerModel().beforeSnapshot(); + } + + public ResourceSnapshotData afterSnapshot() { + return this.innerModel().afterSnapshot(); + } + + public ChangeType changeType() { + return this.innerModel().changeType(); + } + + public List propertyChanges() { + List inner = this.innerModel().propertyChanges(); + if (inner != null) { + return Collections.unmodifiableList(inner); + } else { + return Collections.emptyList(); + } + } + + public ResourceChangeDataInner innerModel() { + return this.innerObject; + } + + private ResourceGraphManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceChangeListImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceChangeListImpl.java new file mode 100644 index 000000000000..cebd7bb16938 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceChangeListImpl.java @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.implementation; + +import com.azure.resourcemanager.resourcegraph.ResourceGraphManager; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeDataInner; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeListInner; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeData; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public final class ResourceChangeListImpl implements ResourceChangeList { + private ResourceChangeListInner innerObject; + + private final ResourceGraphManager serviceManager; + + ResourceChangeListImpl(ResourceChangeListInner innerObject, ResourceGraphManager serviceManager) { + this.innerObject = innerObject; + this.serviceManager = serviceManager; + } + + public List changes() { + List inner = this.innerModel().changes(); + if (inner != null) { + return Collections + .unmodifiableList( + inner + .stream() + .map(inner1 -> new ResourceChangeDataImpl(inner1, this.manager())) + .collect(Collectors.toList())); + } else { + return Collections.emptyList(); + } + } + + public Object skipToken() { + return this.innerModel().skipToken(); + } + + public ResourceChangeListInner innerModel() { + return this.innerObject; + } + + private ResourceGraphManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceGraphClientBuilder.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceGraphClientBuilder.java new file mode 100644 index 000000000000..1240647ffde4 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceGraphClientBuilder.java @@ -0,0 +1,129 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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 ResourceGraphClientImpl type. */ +@ServiceClientBuilder(serviceClients = {ResourceGraphClientImpl.class}) +public final class ResourceGraphClientBuilder { + /* + * server parameter + */ + private String endpoint; + + /** + * Sets server parameter. + * + * @param endpoint the endpoint value. + * @return the ResourceGraphClientBuilder. + */ + public ResourceGraphClientBuilder 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 ResourceGraphClientBuilder. + */ + public ResourceGraphClientBuilder 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 ResourceGraphClientBuilder. + */ + public ResourceGraphClientBuilder 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 ResourceGraphClientBuilder. + */ + public ResourceGraphClientBuilder 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 ResourceGraphClientBuilder. + */ + public ResourceGraphClientBuilder serializerAdapter(SerializerAdapter serializerAdapter) { + this.serializerAdapter = serializerAdapter; + return this; + } + + /** + * Builds an instance of ResourceGraphClientImpl with the provided parameters. + * + * @return an instance of ResourceGraphClientImpl. + */ + public ResourceGraphClientImpl 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(); + } + ResourceGraphClientImpl client = + new ResourceGraphClientImpl(pipeline, serializerAdapter, defaultPollInterval, environment, endpoint); + return client; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceGraphClientImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceGraphClientImpl.java new file mode 100644 index 000000000000..4f135eae6e56 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceGraphClientImpl.java @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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.resourcegraph.fluent.OperationsClient; +import com.azure.resourcemanager.resourcegraph.fluent.ResourceGraphClient; +import com.azure.resourcemanager.resourcegraph.fluent.ResourceProvidersClient; +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 ResourceGraphClientImpl type. */ +@ServiceClient(builder = ResourceGraphClientBuilder.class) +public final class ResourceGraphClientImpl implements ResourceGraphClient { + private final ClientLogger logger = new ClientLogger(ResourceGraphClientImpl.class); + + /** server parameter. */ + private final String endpoint; + + /** + * Gets server parameter. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** Api Version. */ + private final String apiVersion; + + /** + * Gets Api Version. + * + * @return the apiVersion value. + */ + public String getApiVersion() { + return this.apiVersion; + } + + /** The HTTP pipeline to send requests through. */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** The serializer to serialize an object into a string. */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** The default poll interval for long-running operation. */ + private final Duration defaultPollInterval; + + /** + * Gets The default poll interval for long-running operation. + * + * @return the defaultPollInterval value. + */ + public Duration getDefaultPollInterval() { + return this.defaultPollInterval; + } + + /** The ResourceProvidersClient object to access its operations. */ + private final ResourceProvidersClient resourceProviders; + + /** + * Gets the ResourceProvidersClient object to access its operations. + * + * @return the ResourceProvidersClient object. + */ + public ResourceProvidersClient getResourceProviders() { + return this.resourceProviders; + } + + /** The OperationsClient object to access its operations. */ + private final OperationsClient operations; + + /** + * Gets the OperationsClient object to access its operations. + * + * @return the OperationsClient object. + */ + public OperationsClient getOperations() { + return this.operations; + } + + /** + * Initializes an instance of ResourceGraphClient 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 server parameter. + */ + ResourceGraphClientImpl( + HttpPipeline httpPipeline, + SerializerAdapter serializerAdapter, + Duration defaultPollInterval, + AzureEnvironment environment, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.defaultPollInterval = defaultPollInterval; + this.endpoint = endpoint; + this.apiVersion = "2020-04-01-preview"; + this.resourceProviders = new ResourceProvidersClientImpl(this); + this.operations = new OperationsClientImpl(this); + } + + /** + * Gets default client context. + * + * @return the default client context. + */ + public Context getContext() { + return Context.NONE; + } + + /** + * Merges default client context with provided context. + * + * @param context the context to be merged with default client context. + * @return the merged context. + */ + public Context mergeContext(Context context) { + for (Map.Entry entry : this.getContext().getValues().entrySet()) { + context = context.addData(entry.getKey(), entry.getValue()); + } + return context; + } + + /** + * Gets long running operation result. + * + * @param activationResponse the response of activation operation. + * @param httpPipeline the http pipeline. + * @param pollResultType type of poll result. + * @param finalResultType type of final result. + * @param context the context shared by all requests. + * @param type of poll result. + * @param type of final result. + * @return poller flux for poll result and final result. + */ + public PollerFlux, U> getLroResult( + Mono>> activationResponse, + HttpPipeline httpPipeline, + Type pollResultType, + Type finalResultType, + Context context) { + return PollerFactory + .create( + serializerAdapter, + httpPipeline, + pollResultType, + finalResultType, + defaultPollInterval, + activationResponse, + context); + } + + /** + * Gets the final result, or an error, based on last async poll response. + * + * @param response the last async poll response. + * @param type of poll result. + * @param type of final result. + * @return the final result, or an error. + */ + public Mono getLroFinalResultOrError(AsyncPollResponse, U> response) { + if (response.getStatus() != LongRunningOperationStatus.SUCCESSFULLY_COMPLETED) { + String errorMessage; + ManagementError managementError = null; + HttpResponse errorResponse = null; + PollResult.Error lroError = response.getValue().getError(); + if (lroError != null) { + errorResponse = + new HttpResponseImpl( + lroError.getResponseStatusCode(), lroError.getResponseHeaders(), lroError.getResponseBody()); + + errorMessage = response.getValue().getError().getMessage(); + String errorBody = response.getValue().getError().getResponseBody(); + if (errorBody != null) { + // try to deserialize error body to ManagementError + try { + managementError = + this + .getSerializerAdapter() + .deserialize(errorBody, ManagementError.class, SerializerEncoding.JSON); + if (managementError.getCode() == null || managementError.getMessage() == null) { + managementError = null; + } + } catch (IOException 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.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/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceProvidersClientImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceProvidersClientImpl.java new file mode 100644 index 000000000000..0a78497913d6 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceProvidersClientImpl.java @@ -0,0 +1,435 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.implementation; + +import com.azure.core.annotation.BodyParam; +import com.azure.core.annotation.ExpectedResponses; +import com.azure.core.annotation.HeaderParam; +import com.azure.core.annotation.Headers; +import com.azure.core.annotation.Host; +import com.azure.core.annotation.HostParam; +import com.azure.core.annotation.Post; +import com.azure.core.annotation.QueryParam; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceInterface; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.annotation.UnexpectedResponseExceptionType; +import com.azure.core.http.rest.Response; +import com.azure.core.http.rest.RestProxy; +import com.azure.core.management.exception.ManagementException; +import com.azure.core.util.Context; +import com.azure.core.util.FluxUtil; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.resourcegraph.fluent.ResourceProvidersClient; +import com.azure.resourcemanager.resourcegraph.fluent.models.QueryResponseInner; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeDataInner; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeListInner; +import com.azure.resourcemanager.resourcegraph.models.QueryRequest; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeDetailsRequestParameters; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangesRequestParameters; +import reactor.core.publisher.Mono; + +/** An instance of this class provides access to all the operations defined in ResourceProvidersClient. */ +public final class ResourceProvidersClientImpl implements ResourceProvidersClient { + private final ClientLogger logger = new ClientLogger(ResourceProvidersClientImpl.class); + + /** The proxy service used to perform REST calls. */ + private final ResourceProvidersService service; + + /** The service client containing this operation class. */ + private final ResourceGraphClientImpl client; + + /** + * Initializes an instance of ResourceProvidersClientImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ResourceProvidersClientImpl(ResourceGraphClientImpl client) { + this.service = + RestProxy.create(ResourceProvidersService.class, client.getHttpPipeline(), client.getSerializerAdapter()); + this.client = client; + } + + /** + * The interface defining all the services for ResourceGraphClientResourceProviders to be used by the proxy service + * to perform REST calls. + */ + @Host("{$host}") + @ServiceInterface(name = "ResourceGraphClientR") + private interface ResourceProvidersService { + @Headers({"Content-Type: application/json"}) + @Post("/providers/Microsoft.ResourceGraph/resources") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> resources( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") QueryRequest query, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Post("/providers/Microsoft.ResourceGraph/resourceChanges") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> resourceChanges( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ResourceChangesRequestParameters parameters, + @HeaderParam("Accept") String accept, + Context context); + + @Headers({"Content-Type: application/json"}) + @Post("/providers/Microsoft.ResourceGraph/resourceChangeDetails") + @ExpectedResponses({200}) + @UnexpectedResponseExceptionType(ManagementException.class) + Mono> resourceChangeDetails( + @HostParam("$host") String endpoint, + @QueryParam("api-version") String apiVersion, + @BodyParam("application/json") ResourceChangeDetailsRequestParameters parameters, + @HeaderParam("Accept") String accept, + Context context); + } + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> resourcesWithResponseAsync(QueryRequest query) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (query == null) { + return Mono.error(new IllegalArgumentException("Parameter query is required and cannot be null.")); + } else { + query.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service.resources(this.client.getEndpoint(), this.client.getApiVersion(), query, accept, context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> resourcesWithResponseAsync(QueryRequest query, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (query == null) { + return Mono.error(new IllegalArgumentException("Parameter query is required and cannot be null.")); + } else { + query.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service.resources(this.client.getEndpoint(), this.client.getApiVersion(), query, accept, context); + } + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono resourcesAsync(QueryRequest query) { + return resourcesWithResponseAsync(query) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public QueryResponseInner resources(QueryRequest query) { + return resourcesAsync(query).block(); + } + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response resourcesWithResponse(QueryRequest query, Context context) { + return resourcesWithResponseAsync(query, context).block(); + } + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> resourceChangesWithResponseAsync( + ResourceChangesRequestParameters parameters) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .resourceChanges( + this.client.getEndpoint(), this.client.getApiVersion(), parameters, accept, context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> resourceChangesWithResponseAsync( + ResourceChangesRequestParameters parameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .resourceChanges(this.client.getEndpoint(), this.client.getApiVersion(), parameters, accept, context); + } + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono resourceChangesAsync(ResourceChangesRequestParameters parameters) { + return resourceChangesWithResponseAsync(parameters) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceChangeListInner resourceChanges(ResourceChangesRequestParameters parameters) { + return resourceChangesAsync(parameters).block(); + } + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response resourceChangesWithResponse( + ResourceChangesRequestParameters parameters, Context context) { + return resourceChangesWithResponseAsync(parameters, context).block(); + } + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> resourceChangeDetailsWithResponseAsync( + ResourceChangeDetailsRequestParameters parameters) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + return FluxUtil + .withContext( + context -> + service + .resourceChangeDetails( + this.client.getEndpoint(), this.client.getApiVersion(), parameters, accept, context)) + .subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext()))); + } + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono> resourceChangeDetailsWithResponseAsync( + ResourceChangeDetailsRequestParameters parameters, Context context) { + if (this.client.getEndpoint() == null) { + return Mono + .error( + new IllegalArgumentException( + "Parameter this.client.getEndpoint() is required and cannot be null.")); + } + if (parameters == null) { + return Mono.error(new IllegalArgumentException("Parameter parameters is required and cannot be null.")); + } else { + parameters.validate(); + } + final String accept = "application/json"; + context = this.client.mergeContext(context); + return service + .resourceChangeDetails(this.client.getEndpoint(), this.client.getApiVersion(), parameters, accept, context); + } + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + private Mono resourceChangeDetailsAsync( + ResourceChangeDetailsRequestParameters parameters) { + return resourceChangeDetailsWithResponseAsync(parameters) + .flatMap( + (Response res) -> { + if (res.getValue() != null) { + return Mono.just(res.getValue()); + } else { + return Mono.empty(); + } + }); + } + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public ResourceChangeDataInner resourceChangeDetails(ResourceChangeDetailsRequestParameters parameters) { + return resourceChangeDetailsAsync(parameters).block(); + } + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response resourceChangeDetailsWithResponse( + ResourceChangeDetailsRequestParameters parameters, Context context) { + return resourceChangeDetailsWithResponseAsync(parameters, context).block(); + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceProvidersImpl.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceProvidersImpl.java new file mode 100644 index 000000000000..1667706b2d31 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/ResourceProvidersImpl.java @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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.resourcegraph.ResourceGraphManager; +import com.azure.resourcemanager.resourcegraph.fluent.ResourceProvidersClient; +import com.azure.resourcemanager.resourcegraph.fluent.models.QueryResponseInner; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeDataInner; +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeListInner; +import com.azure.resourcemanager.resourcegraph.models.QueryRequest; +import com.azure.resourcemanager.resourcegraph.models.QueryResponse; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeData; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeDetailsRequestParameters; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangeList; +import com.azure.resourcemanager.resourcegraph.models.ResourceChangesRequestParameters; +import com.azure.resourcemanager.resourcegraph.models.ResourceProviders; +import com.fasterxml.jackson.annotation.JsonIgnore; + +public final class ResourceProvidersImpl implements ResourceProviders { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceProvidersImpl.class); + + private final ResourceProvidersClient innerClient; + + private final ResourceGraphManager serviceManager; + + public ResourceProvidersImpl(ResourceProvidersClient innerClient, ResourceGraphManager serviceManager) { + this.innerClient = innerClient; + this.serviceManager = serviceManager; + } + + public QueryResponse resources(QueryRequest query) { + QueryResponseInner inner = this.serviceClient().resources(query); + if (inner != null) { + return new QueryResponseImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response resourcesWithResponse(QueryRequest query, Context context) { + Response inner = this.serviceClient().resourcesWithResponse(query, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new QueryResponseImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public ResourceChangeList resourceChanges(ResourceChangesRequestParameters parameters) { + ResourceChangeListInner inner = this.serviceClient().resourceChanges(parameters); + if (inner != null) { + return new ResourceChangeListImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response resourceChangesWithResponse( + ResourceChangesRequestParameters parameters, Context context) { + Response inner = this.serviceClient().resourceChangesWithResponse(parameters, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ResourceChangeListImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + public ResourceChangeData resourceChangeDetails(ResourceChangeDetailsRequestParameters parameters) { + ResourceChangeDataInner inner = this.serviceClient().resourceChangeDetails(parameters); + if (inner != null) { + return new ResourceChangeDataImpl(inner, this.manager()); + } else { + return null; + } + } + + public Response resourceChangeDetailsWithResponse( + ResourceChangeDetailsRequestParameters parameters, Context context) { + Response inner = + this.serviceClient().resourceChangeDetailsWithResponse(parameters, context); + if (inner != null) { + return new SimpleResponse<>( + inner.getRequest(), + inner.getStatusCode(), + inner.getHeaders(), + new ResourceChangeDataImpl(inner.getValue(), this.manager())); + } else { + return null; + } + } + + private ResourceProvidersClient serviceClient() { + return this.innerClient; + } + + private ResourceGraphManager manager() { + return this.serviceManager; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/Utils.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/Utils.java new file mode 100644 index 000000000000..5e672f9621a8 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/Utils.java @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.implementation; + +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; + +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; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/package-info.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/implementation/package-info.java new file mode 100644 index 000000000000..2209556f4f81 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/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 ResourceGraphClient. Azure Resource Graph API Reference. */ +package com.azure.resourcemanager.resourcegraph.implementation; diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ChangeCategory.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ChangeCategory.java new file mode 100644 index 000000000000..443f99c8a8c1 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ChangeCategory.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for ChangeCategory. */ +public enum ChangeCategory { + /** Enum value User. */ + USER("User"), + + /** Enum value System. */ + SYSTEM("System"); + + /** The actual serialized value for a ChangeCategory instance. */ + private final String value; + + ChangeCategory(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ChangeCategory instance. + * + * @param value the serialized value to parse. + * @return the parsed ChangeCategory object, or null if unable to parse. + */ + @JsonCreator + public static ChangeCategory fromString(String value) { + ChangeCategory[] items = ChangeCategory.values(); + for (ChangeCategory item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ChangeType.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ChangeType.java new file mode 100644 index 000000000000..84de98f11dd6 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ChangeType.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.resourcegraph.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for ChangeType. */ +public enum ChangeType { + /** Enum value Create. */ + CREATE("Create"), + + /** Enum value Update. */ + UPDATE("Update"), + + /** Enum value Delete. */ + DELETE("Delete"); + + /** The actual serialized value for a ChangeType instance. */ + private final String value; + + ChangeType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ChangeType instance. + * + * @param value the serialized value to parse. + * @return the parsed ChangeType object, or null if unable to parse. + */ + @JsonCreator + public static ChangeType fromString(String value) { + ChangeType[] items = ChangeType.values(); + for (ChangeType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Column.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Column.java new file mode 100644 index 000000000000..ba445a7f0bf9 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Column.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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; + +/** Query result column descriptor. */ +@Fluent +public final class Column { + @JsonIgnore private final ClientLogger logger = new ClientLogger(Column.class); + + /* + * Column name. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /* + * Column data type. + */ + @JsonProperty(value = "type", required = true) + private ColumnDataType type; + + /** + * Get the name property: Column name. + * + * @return the name value. + */ + public String name() { + return this.name; + } + + /** + * Set the name property: Column name. + * + * @param name the name value to set. + * @return the Column object itself. + */ + public Column withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type property: Column data type. + * + * @return the type value. + */ + public ColumnDataType type() { + return this.type; + } + + /** + * Set the type property: Column data type. + * + * @param type the type value to set. + * @return the Column object itself. + */ + public Column withType(ColumnDataType type) { + this.type = type; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (name() == null) { + throw logger + .logExceptionAsError(new IllegalArgumentException("Missing required property name in model Column")); + } + if (type() == null) { + throw logger + .logExceptionAsError(new IllegalArgumentException("Missing required property type in model Column")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ColumnDataType.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ColumnDataType.java new file mode 100644 index 000000000000..d68af9d296ae --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ColumnDataType.java @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for ColumnDataType. */ +public enum ColumnDataType { + /** Enum value string. */ + STRING("string"), + + /** Enum value integer. */ + INTEGER("integer"), + + /** Enum value number. */ + NUMBER("number"), + + /** Enum value boolean. */ + BOOLEAN("boolean"), + + /** Enum value object. */ + OBJECT("object"); + + /** The actual serialized value for a ColumnDataType instance. */ + private final String value; + + ColumnDataType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ColumnDataType instance. + * + * @param value the serialized value to parse. + * @return the parsed ColumnDataType object, or null if unable to parse. + */ + @JsonCreator + public static ColumnDataType fromString(String value) { + ColumnDataType[] items = ColumnDataType.values(); + for (ColumnDataType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/DateTimeInterval.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/DateTimeInterval.java new file mode 100644 index 000000000000..564c3d43d400 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/DateTimeInterval.java @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** An interval in time specifying the date and time for the inclusive start and exclusive end, i.e. `[start, end)`. */ +@Fluent +public class DateTimeInterval { + @JsonIgnore private final ClientLogger logger = new ClientLogger(DateTimeInterval.class); + + /* + * A datetime indicating the inclusive/closed start of the time interval, + * i.e. `[`**`start`**`, end)`. Specifying a `start` that occurs + * chronologically after `end` will result in an error. + */ + @JsonProperty(value = "start", required = true) + private OffsetDateTime start; + + /* + * A datetime indicating the exclusive/open end of the time interval, i.e. + * `[start, `**`end`**`)`. Specifying an `end` that occurs chronologically + * before `start` will result in an error. + */ + @JsonProperty(value = "end", required = true) + private OffsetDateTime end; + + /** + * Get the start property: A datetime indicating the inclusive/closed start of the time interval, i.e. + * `[`**`start`**`, end)`. Specifying a `start` that occurs chronologically after `end` will result in an error. + * + * @return the start value. + */ + public OffsetDateTime start() { + return this.start; + } + + /** + * Set the start property: A datetime indicating the inclusive/closed start of the time interval, i.e. + * `[`**`start`**`, end)`. Specifying a `start` that occurs chronologically after `end` will result in an error. + * + * @param start the start value to set. + * @return the DateTimeInterval object itself. + */ + public DateTimeInterval withStart(OffsetDateTime start) { + this.start = start; + return this; + } + + /** + * Get the end property: A datetime indicating the exclusive/open end of the time interval, i.e. `[start, + * `**`end`**`)`. Specifying an `end` that occurs chronologically before `start` will result in an error. + * + * @return the end value. + */ + public OffsetDateTime end() { + return this.end; + } + + /** + * Set the end property: A datetime indicating the exclusive/open end of the time interval, i.e. `[start, + * `**`end`**`)`. Specifying an `end` that occurs chronologically before `start` will result in an error. + * + * @param end the end value to set. + * @return the DateTimeInterval object itself. + */ + public DateTimeInterval withEnd(OffsetDateTime end) { + this.end = end; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (start() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property start in model DateTimeInterval")); + } + if (end() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property end in model DateTimeInterval")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ErrorDetails.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ErrorDetails.java new file mode 100644 index 000000000000..ab08800b6675 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ErrorDetails.java @@ -0,0 +1,124 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.HashMap; +import java.util.Map; + +/** Error details. */ +@Fluent +public final class ErrorDetails { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ErrorDetails.class); + + /* + * Error code identifying the specific error. + */ + @JsonProperty(value = "code", required = true) + private String code; + + /* + * A human readable error message. + */ + @JsonProperty(value = "message", required = true) + private String message; + + /* + * Error details. + */ + @JsonIgnore private Map additionalProperties; + + /** + * Get the code property: Error code identifying the specific error. + * + * @return the code value. + */ + public String code() { + return this.code; + } + + /** + * Set the code property: Error code identifying the specific error. + * + * @param code the code value to set. + * @return the ErrorDetails object itself. + */ + public ErrorDetails withCode(String code) { + this.code = code; + return this; + } + + /** + * Get the message property: A human readable error message. + * + * @return the message value. + */ + public String message() { + return this.message; + } + + /** + * Set the message property: A human readable error message. + * + * @param message the message value to set. + * @return the ErrorDetails object itself. + */ + public ErrorDetails withMessage(String message) { + this.message = message; + return this; + } + + /** + * Get the additionalProperties property: Error details. + * + * @return the additionalProperties value. + */ + @JsonAnyGetter + public Map additionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Error details. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ErrorDetails object itself. + */ + public ErrorDetails withAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + @JsonAnySetter + void withAdditionalProperties(String key, Object value) { + if (additionalProperties == null) { + additionalProperties = new HashMap<>(); + } + additionalProperties.put(key, value); + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (code() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property code in model ErrorDetails")); + } + if (message() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property message in model ErrorDetails")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Facet.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Facet.java new file mode 100644 index 000000000000..4be60198dd4f --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Facet.java @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** A facet containing additional statistics on the response of a query. Can be either FacetResult or FacetError. */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "resultType", + defaultImpl = Facet.class) +@JsonTypeName("Facet") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "FacetResult", value = FacetResult.class), + @JsonSubTypes.Type(name = "FacetError", value = FacetError.class) +}) +@Fluent +public class Facet { + @JsonIgnore private final ClientLogger logger = new ClientLogger(Facet.class); + + /* + * Facet expression, same as in the corresponding facet request. + */ + @JsonProperty(value = "expression", required = true) + private String expression; + + /** + * Get the expression property: Facet expression, same as in the corresponding facet request. + * + * @return the expression value. + */ + public String expression() { + return this.expression; + } + + /** + * Set the expression property: Facet expression, same as in the corresponding facet request. + * + * @param expression the expression value to set. + * @return the Facet object itself. + */ + public Facet withExpression(String expression) { + this.expression = expression; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (expression() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property expression in model Facet")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetError.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetError.java new file mode 100644 index 000000000000..69db15ab9ea0 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetError.java @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import java.util.List; + +/** A facet whose execution resulted in an error. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType") +@JsonTypeName("FacetError") +@Fluent +public final class FacetError extends Facet { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FacetError.class); + + /* + * An array containing detected facet errors with details. + */ + @JsonProperty(value = "errors", required = true) + private List errors; + + /** + * Get the errors property: An array containing detected facet errors with details. + * + * @return the errors value. + */ + public List errors() { + return this.errors; + } + + /** + * Set the errors property: An array containing detected facet errors with details. + * + * @param errors the errors value to set. + * @return the FacetError object itself. + */ + public FacetError withErrors(List errors) { + this.errors = errors; + return this; + } + + /** {@inheritDoc} */ + @Override + public FacetError withExpression(String expression) { + super.withExpression(expression); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (errors() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property errors in model FacetError")); + } else { + errors().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetRequest.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetRequest.java new file mode 100644 index 000000000000..00717c1ff399 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetRequest.java @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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; + +/** A request to compute additional statistics (facets) over the query results. */ +@Fluent +public final class FacetRequest { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FacetRequest.class); + + /* + * The column or list of columns to summarize by + */ + @JsonProperty(value = "expression", required = true) + private String expression; + + /* + * The options for facet evaluation + */ + @JsonProperty(value = "options") + private FacetRequestOptions options; + + /** + * Get the expression property: The column or list of columns to summarize by. + * + * @return the expression value. + */ + public String expression() { + return this.expression; + } + + /** + * Set the expression property: The column or list of columns to summarize by. + * + * @param expression the expression value to set. + * @return the FacetRequest object itself. + */ + public FacetRequest withExpression(String expression) { + this.expression = expression; + return this; + } + + /** + * Get the options property: The options for facet evaluation. + * + * @return the options value. + */ + public FacetRequestOptions options() { + return this.options; + } + + /** + * Set the options property: The options for facet evaluation. + * + * @param options the options value to set. + * @return the FacetRequest object itself. + */ + public FacetRequest withOptions(FacetRequestOptions options) { + this.options = options; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (expression() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property expression in model FacetRequest")); + } + if (options() != null) { + options().validate(); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetRequestOptions.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetRequestOptions.java new file mode 100644 index 000000000000..fc06c6474c25 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetRequestOptions.java @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The options for facet evaluation. */ +@Fluent +public final class FacetRequestOptions { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FacetRequestOptions.class); + + /* + * The column name or query expression to sort on. Defaults to count if not + * present. + */ + @JsonProperty(value = "sortBy") + private String sortBy; + + /* + * The sorting order by the selected column (count by default). + */ + @JsonProperty(value = "sortOrder") + private FacetSortOrder sortOrder; + + /* + * Specifies the filter condition for the 'where' clause which will be run + * on main query's result, just before the actual faceting. + */ + @JsonProperty(value = "filter") + private String filter; + + /* + * The maximum number of facet rows that should be returned. + */ + @JsonProperty(value = "$top") + private Integer top; + + /** + * Get the sortBy property: The column name or query expression to sort on. Defaults to count if not present. + * + * @return the sortBy value. + */ + public String sortBy() { + return this.sortBy; + } + + /** + * Set the sortBy property: The column name or query expression to sort on. Defaults to count if not present. + * + * @param sortBy the sortBy value to set. + * @return the FacetRequestOptions object itself. + */ + public FacetRequestOptions withSortBy(String sortBy) { + this.sortBy = sortBy; + return this; + } + + /** + * Get the sortOrder property: The sorting order by the selected column (count by default). + * + * @return the sortOrder value. + */ + public FacetSortOrder sortOrder() { + return this.sortOrder; + } + + /** + * Set the sortOrder property: The sorting order by the selected column (count by default). + * + * @param sortOrder the sortOrder value to set. + * @return the FacetRequestOptions object itself. + */ + public FacetRequestOptions withSortOrder(FacetSortOrder sortOrder) { + this.sortOrder = sortOrder; + return this; + } + + /** + * Get the filter property: Specifies the filter condition for the 'where' clause which will be run on main query's + * result, just before the actual faceting. + * + * @return the filter value. + */ + public String filter() { + return this.filter; + } + + /** + * Set the filter property: Specifies the filter condition for the 'where' clause which will be run on main query's + * result, just before the actual faceting. + * + * @param filter the filter value to set. + * @return the FacetRequestOptions object itself. + */ + public FacetRequestOptions withFilter(String filter) { + this.filter = filter; + return this; + } + + /** + * Get the top property: The maximum number of facet rows that should be returned. + * + * @return the top value. + */ + public Integer top() { + return this.top; + } + + /** + * Set the top property: The maximum number of facet rows that should be returned. + * + * @param top the top value to set. + * @return the FacetRequestOptions object itself. + */ + public FacetRequestOptions withTop(Integer top) { + this.top = top; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetResult.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetResult.java new file mode 100644 index 000000000000..8daadb0c2869 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetResult.java @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** Successfully executed facet containing additional statistics on the response of a query. */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType") +@JsonTypeName("FacetResult") +@Fluent +public final class FacetResult extends Facet { + @JsonIgnore private final ClientLogger logger = new ClientLogger(FacetResult.class); + + /* + * Number of total records in the facet results. + */ + @JsonProperty(value = "totalRecords", required = true) + private long totalRecords; + + /* + * Number of records returned in the facet response. + */ + @JsonProperty(value = "count", required = true) + private int count; + + /* + * A table containing the desired facets. Only present if the facet is + * valid. + */ + @JsonProperty(value = "data", required = true) + private Object data; + + /** + * Get the totalRecords property: Number of total records in the facet results. + * + * @return the totalRecords value. + */ + public long totalRecords() { + return this.totalRecords; + } + + /** + * Set the totalRecords property: Number of total records in the facet results. + * + * @param totalRecords the totalRecords value to set. + * @return the FacetResult object itself. + */ + public FacetResult withTotalRecords(long totalRecords) { + this.totalRecords = totalRecords; + return this; + } + + /** + * Get the count property: Number of records returned in the facet response. + * + * @return the count value. + */ + public int count() { + return this.count; + } + + /** + * Set the count property: Number of records returned in the facet response. + * + * @param count the count value to set. + * @return the FacetResult object itself. + */ + public FacetResult withCount(int count) { + this.count = count; + return this; + } + + /** + * Get the data property: A table containing the desired facets. Only present if the facet is valid. + * + * @return the data value. + */ + public Object data() { + return this.data; + } + + /** + * Set the data property: A table containing the desired facets. Only present if the facet is valid. + * + * @param data the data value to set. + * @return the FacetResult object itself. + */ + public FacetResult withData(Object data) { + this.data = data; + return this; + } + + /** {@inheritDoc} */ + @Override + public FacetResult withExpression(String expression) { + super.withExpression(expression); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + if (data() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property data in model FacetResult")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetSortOrder.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetSortOrder.java new file mode 100644 index 000000000000..03d27b3b22b8 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/FacetSortOrder.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for FacetSortOrder. */ +public enum FacetSortOrder { + /** Enum value asc. */ + ASC("asc"), + + /** Enum value desc. */ + DESC("desc"); + + /** The actual serialized value for a FacetSortOrder instance. */ + private final String value; + + FacetSortOrder(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a FacetSortOrder instance. + * + * @param value the serialized value to parse. + * @return the parsed FacetSortOrder object, or null if unable to parse. + */ + @JsonCreator + public static FacetSortOrder fromString(String value) { + FacetSortOrder[] items = FacetSortOrder.values(); + for (FacetSortOrder item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Operation.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Operation.java new file mode 100644 index 000000000000..7a7868bbacab --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Operation.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.resourcemanager.resourcegraph.fluent.models.OperationInner; + +/** An immutable client-side representation of Operation. */ +public interface Operation { + /** + * Gets the name property: Operation name: {provider}/{resource}/{operation}. + * + * @return the name value. + */ + String name(); + + /** + * Gets the display property: Display metadata associated with the operation. + * + * @return the display value. + */ + OperationDisplay display(); + + /** + * Gets the origin property: The origin of operations. + * + * @return the origin value. + */ + String origin(); + + /** + * Gets the inner com.azure.resourcemanager.resourcegraph.fluent.models.OperationInner object. + * + * @return the inner object. + */ + OperationInner innerModel(); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/OperationDisplay.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/OperationDisplay.java new file mode 100644 index 000000000000..97c40587d302 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/OperationDisplay.java @@ -0,0 +1,128 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.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; + +/** Display metadata associated with the operation. */ +@Fluent +public final class OperationDisplay { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationDisplay.class); + + /* + * Service provider: Microsoft Resource Graph. + */ + @JsonProperty(value = "provider") + private String provider; + + /* + * Resource on which the operation is performed etc. + */ + @JsonProperty(value = "resource") + private String resource; + + /* + * Type of operation: get, read, delete, etc. + */ + @JsonProperty(value = "operation") + private String operation; + + /* + * Description for the operation. + */ + @JsonProperty(value = "description") + private String description; + + /** + * Get the provider property: Service provider: Microsoft Resource Graph. + * + * @return the provider value. + */ + public String provider() { + return this.provider; + } + + /** + * Set the provider property: Service provider: Microsoft Resource Graph. + * + * @param provider the provider value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withProvider(String provider) { + this.provider = provider; + return this; + } + + /** + * Get the resource property: Resource on which the operation is performed etc. + * + * @return the resource value. + */ + public String resource() { + return this.resource; + } + + /** + * Set the resource property: Resource on which the operation is performed etc. + * + * @param resource the resource value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withResource(String resource) { + this.resource = resource; + return this; + } + + /** + * Get the operation property: Type of operation: get, read, delete, etc. + * + * @return the operation value. + */ + public String operation() { + return this.operation; + } + + /** + * Set the operation property: Type of operation: get, read, delete, etc. + * + * @param operation the operation value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withOperation(String operation) { + this.operation = operation; + return this; + } + + /** + * Get the description property: Description for the operation. + * + * @return the description value. + */ + public String description() { + return this.description; + } + + /** + * Set the description property: Description for the operation. + * + * @param description the description value to set. + * @return the OperationDisplay object itself. + */ + public OperationDisplay withDescription(String description) { + this.description = description; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/OperationListResult.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/OperationListResult.java new file mode 100644 index 000000000000..3ba05ce5a7de --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/OperationListResult.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.azure.resourcemanager.resourcegraph.fluent.models.OperationInner; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** + * Result of the request to list Resource Graph operations. It contains a list of operations and a URL link to get the + * next set of results. + */ +@Fluent +public final class OperationListResult { + @JsonIgnore private final ClientLogger logger = new ClientLogger(OperationListResult.class); + + /* + * List of Resource Graph operations supported by the Resource Graph + * resource provider. + */ + @JsonProperty(value = "value") + private List value; + + /** + * Get the value property: List of Resource Graph operations supported by the Resource Graph resource provider. + * + * @return the value value. + */ + public List value() { + return this.value; + } + + /** + * Set the value property: List of Resource Graph operations supported by the Resource Graph resource provider. + * + * @param value the value value to set. + * @return the OperationListResult object itself. + */ + public OperationListResult withValue(List value) { + this.value = value; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (value() != null) { + value().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Operations.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Operations.java new file mode 100644 index 000000000000..fd7775dca3aa --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/Operations.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.http.rest.PagedIterable; +import com.azure.core.util.Context; + +/** Resource collection API of Operations. */ +public interface Operations { + /** + * Lists all of the available REST API operations. + * + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + PagedIterable list(); + + /** + * Lists all of the available REST API operations. + * + * @param context The context to associate with this operation. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws com.azure.core.management.exception.ManagementException thrown if the request is rejected by server. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return result of the request to list Resource Graph operations. + */ + PagedIterable list(Context context); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/PropertyChangeType.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/PropertyChangeType.java new file mode 100644 index 000000000000..2de713f05faf --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/PropertyChangeType.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.resourcegraph.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for PropertyChangeType. */ +public enum PropertyChangeType { + /** Enum value Insert. */ + INSERT("Insert"), + + /** Enum value Update. */ + UPDATE("Update"), + + /** Enum value Remove. */ + REMOVE("Remove"); + + /** The actual serialized value for a PropertyChangeType instance. */ + private final String value; + + PropertyChangeType(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a PropertyChangeType instance. + * + * @param value the serialized value to parse. + * @return the parsed PropertyChangeType object, or null if unable to parse. + */ + @JsonCreator + public static PropertyChangeType fromString(String value) { + PropertyChangeType[] items = PropertyChangeType.values(); + for (PropertyChangeType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryRequest.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryRequest.java new file mode 100644 index 000000000000..dad1eba9d141 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryRequest.java @@ -0,0 +1,166 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Describes a query to be executed. */ +@Fluent +public final class QueryRequest { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QueryRequest.class); + + /* + * Azure subscriptions against which to execute the query. + */ + @JsonProperty(value = "subscriptions") + private List subscriptions; + + /* + * The management group identifier. + */ + @JsonProperty(value = "managementGroupId") + private String managementGroupId; + + /* + * The resources query. + */ + @JsonProperty(value = "query", required = true) + private String query; + + /* + * The query evaluation options + */ + @JsonProperty(value = "options") + private QueryRequestOptions options; + + /* + * An array of facet requests to be computed against the query result. + */ + @JsonProperty(value = "facets") + private List facets; + + /** + * Get the subscriptions property: Azure subscriptions against which to execute the query. + * + * @return the subscriptions value. + */ + public List subscriptions() { + return this.subscriptions; + } + + /** + * Set the subscriptions property: Azure subscriptions against which to execute the query. + * + * @param subscriptions the subscriptions value to set. + * @return the QueryRequest object itself. + */ + public QueryRequest withSubscriptions(List subscriptions) { + this.subscriptions = subscriptions; + return this; + } + + /** + * Get the managementGroupId property: The management group identifier. + * + * @return the managementGroupId value. + */ + public String managementGroupId() { + return this.managementGroupId; + } + + /** + * Set the managementGroupId property: The management group identifier. + * + * @param managementGroupId the managementGroupId value to set. + * @return the QueryRequest object itself. + */ + public QueryRequest withManagementGroupId(String managementGroupId) { + this.managementGroupId = managementGroupId; + return this; + } + + /** + * Get the query property: The resources query. + * + * @return the query value. + */ + public String query() { + return this.query; + } + + /** + * Set the query property: The resources query. + * + * @param query the query value to set. + * @return the QueryRequest object itself. + */ + public QueryRequest withQuery(String query) { + this.query = query; + return this; + } + + /** + * Get the options property: The query evaluation options. + * + * @return the options value. + */ + public QueryRequestOptions options() { + return this.options; + } + + /** + * Set the options property: The query evaluation options. + * + * @param options the options value to set. + * @return the QueryRequest object itself. + */ + public QueryRequest withOptions(QueryRequestOptions options) { + this.options = options; + return this; + } + + /** + * Get the facets property: An array of facet requests to be computed against the query result. + * + * @return the facets value. + */ + public List facets() { + return this.facets; + } + + /** + * Set the facets property: An array of facet requests to be computed against the query result. + * + * @param facets the facets value to set. + * @return the QueryRequest object itself. + */ + public QueryRequest withFacets(List facets) { + this.facets = facets; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (query() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property query in model QueryRequest")); + } + if (options() != null) { + options().validate(); + } + if (facets() != null) { + facets().forEach(e -> e.validate()); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryRequestOptions.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryRequestOptions.java new file mode 100644 index 000000000000..95e2869703c1 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryRequestOptions.java @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The options for query evaluation. */ +@Fluent +public final class QueryRequestOptions { + @JsonIgnore private final ClientLogger logger = new ClientLogger(QueryRequestOptions.class); + + /* + * Continuation token for pagination, capturing the next page size and + * offset, as well as the context of the query. + */ + @JsonProperty(value = "$skipToken") + private String skipToken; + + /* + * The maximum number of rows that the query should return. Overrides the + * page size when ```$skipToken``` property is present. + */ + @JsonProperty(value = "$top") + private Integer top; + + /* + * The number of rows to skip from the beginning of the results. Overrides + * the next page offset when ```$skipToken``` property is present. + */ + @JsonProperty(value = "$skip") + private Integer skip; + + /* + * Defines in which format query result returned. + */ + @JsonProperty(value = "resultFormat") + private ResultFormat resultFormat; + + /** + * Get the skipToken property: Continuation token for pagination, capturing the next page size and offset, as well + * as the context of the query. + * + * @return the skipToken value. + */ + public String skipToken() { + return this.skipToken; + } + + /** + * Set the skipToken property: Continuation token for pagination, capturing the next page size and offset, as well + * as the context of the query. + * + * @param skipToken the skipToken value to set. + * @return the QueryRequestOptions object itself. + */ + public QueryRequestOptions withSkipToken(String skipToken) { + this.skipToken = skipToken; + return this; + } + + /** + * Get the top property: The maximum number of rows that the query should return. Overrides the page size when + * ```$skipToken``` property is present. + * + * @return the top value. + */ + public Integer top() { + return this.top; + } + + /** + * Set the top property: The maximum number of rows that the query should return. Overrides the page size when + * ```$skipToken``` property is present. + * + * @param top the top value to set. + * @return the QueryRequestOptions object itself. + */ + public QueryRequestOptions withTop(Integer top) { + this.top = top; + return this; + } + + /** + * Get the skip property: The number of rows to skip from the beginning of the results. Overrides the next page + * offset when ```$skipToken``` property is present. + * + * @return the skip value. + */ + public Integer skip() { + return this.skip; + } + + /** + * Set the skip property: The number of rows to skip from the beginning of the results. Overrides the next page + * offset when ```$skipToken``` property is present. + * + * @param skip the skip value to set. + * @return the QueryRequestOptions object itself. + */ + public QueryRequestOptions withSkip(Integer skip) { + this.skip = skip; + return this; + } + + /** + * Get the resultFormat property: Defines in which format query result returned. + * + * @return the resultFormat value. + */ + public ResultFormat resultFormat() { + return this.resultFormat; + } + + /** + * Set the resultFormat property: Defines in which format query result returned. + * + * @param resultFormat the resultFormat value to set. + * @return the QueryRequestOptions object itself. + */ + public QueryRequestOptions withResultFormat(ResultFormat resultFormat) { + this.resultFormat = resultFormat; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryResponse.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryResponse.java new file mode 100644 index 000000000000..d323f0dba544 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/QueryResponse.java @@ -0,0 +1,62 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.resourcemanager.resourcegraph.fluent.models.QueryResponseInner; +import java.util.List; + +/** An immutable client-side representation of QueryResponse. */ +public interface QueryResponse { + /** + * Gets the totalRecords property: Number of total records matching the query. + * + * @return the totalRecords value. + */ + long totalRecords(); + + /** + * Gets the count property: Number of records returned in the current response. In the case of paging, this is the + * number of records in the current page. + * + * @return the count value. + */ + long count(); + + /** + * Gets the resultTruncated property: Indicates whether the query results are truncated. + * + * @return the resultTruncated value. + */ + ResultTruncated resultTruncated(); + + /** + * Gets the skipToken property: When present, the value can be passed to a subsequent query call (together with the + * same query and subscriptions used in the current request) to retrieve the next page of data. + * + * @return the skipToken value. + */ + String skipToken(); + + /** + * Gets the data property: Query output in tabular format. + * + * @return the data value. + */ + Object data(); + + /** + * Gets the facets property: Query facets. + * + * @return the facets value. + */ + List facets(); + + /** + * Gets the inner com.azure.resourcemanager.resourcegraph.fluent.models.QueryResponseInner object. + * + * @return the inner object. + */ + QueryResponseInner innerModel(); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeData.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeData.java new file mode 100644 index 000000000000..bc7ba989e2dd --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeData.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeDataInner; +import java.util.List; + +/** An immutable client-side representation of ResourceChangeData. */ +public interface ResourceChangeData { + /** + * Gets the changeId property: The change ID. Valid and unique within the specified resource only. + * + * @return the changeId value. + */ + String changeId(); + + /** + * Gets the beforeSnapshot property: The snapshot before the change. + * + * @return the beforeSnapshot value. + */ + ResourceSnapshotData beforeSnapshot(); + + /** + * Gets the afterSnapshot property: The snapshot after the change. + * + * @return the afterSnapshot value. + */ + ResourceSnapshotData afterSnapshot(); + + /** + * Gets the changeType property: The change type for snapshot. PropertyChanges will be provided in case of Update + * change type. + * + * @return the changeType value. + */ + ChangeType changeType(); + + /** + * Gets the propertyChanges property: An array of resource property change. + * + * @return the propertyChanges value. + */ + List propertyChanges(); + + /** + * Gets the inner com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeDataInner object. + * + * @return the inner object. + */ + ResourceChangeDataInner innerModel(); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDataAfterSnapshot.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDataAfterSnapshot.java new file mode 100644 index 000000000000..4904aa479775 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDataAfterSnapshot.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.time.OffsetDateTime; + +/** The snapshot after the change. */ +@Immutable +public final class ResourceChangeDataAfterSnapshot extends ResourceSnapshotData { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceChangeDataAfterSnapshot.class); + + /** {@inheritDoc} */ + @Override + public ResourceChangeDataAfterSnapshot withTimestamp(OffsetDateTime timestamp) { + super.withTimestamp(timestamp); + return this; + } + + /** {@inheritDoc} */ + @Override + public ResourceChangeDataAfterSnapshot withContent(Object content) { + super.withContent(content); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDataBeforeSnapshot.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDataBeforeSnapshot.java new file mode 100644 index 000000000000..05274bce3e78 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDataBeforeSnapshot.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.time.OffsetDateTime; + +/** The snapshot before the change. */ +@Immutable +public final class ResourceChangeDataBeforeSnapshot extends ResourceSnapshotData { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceChangeDataBeforeSnapshot.class); + + /** {@inheritDoc} */ + @Override + public ResourceChangeDataBeforeSnapshot withTimestamp(OffsetDateTime timestamp) { + super.withTimestamp(timestamp); + return this; + } + + /** {@inheritDoc} */ + @Override + public ResourceChangeDataBeforeSnapshot withContent(Object content) { + super.withContent(content); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDetailsRequestParameters.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDetailsRequestParameters.java new file mode 100644 index 000000000000..8f870fd6a6f6 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeDetailsRequestParameters.java @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The parameters for a specific change details request. */ +@Fluent +public final class ResourceChangeDetailsRequestParameters { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceChangeDetailsRequestParameters.class); + + /* + * Specifies the resource for a change details request. + */ + @JsonProperty(value = "resourceId", required = true) + private String resourceId; + + /* + * Specifies the change ID. + */ + @JsonProperty(value = "changeId", required = true) + private String changeId; + + /** + * Get the resourceId property: Specifies the resource for a change details request. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: Specifies the resource for a change details request. + * + * @param resourceId the resourceId value to set. + * @return the ResourceChangeDetailsRequestParameters object itself. + */ + public ResourceChangeDetailsRequestParameters withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Get the changeId property: Specifies the change ID. + * + * @return the changeId value. + */ + public String changeId() { + return this.changeId; + } + + /** + * Set the changeId property: Specifies the change ID. + * + * @param changeId the changeId value to set. + * @return the ResourceChangeDetailsRequestParameters object itself. + */ + public ResourceChangeDetailsRequestParameters withChangeId(String changeId) { + this.changeId = changeId; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (resourceId() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property resourceId in model ResourceChangeDetailsRequestParameters")); + } + if (changeId() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property changeId in model ResourceChangeDetailsRequestParameters")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeList.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeList.java new file mode 100644 index 000000000000..b9fbc2f1986f --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangeList.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeListInner; +import java.util.List; + +/** An immutable client-side representation of ResourceChangeList. */ +public interface ResourceChangeList { + /** + * Gets the changes property: The pageable value returned by the operation, i.e. a list of changes to the resource. + * + *

- The list is ordered from the most recent changes to the least recent changes. - This list will be empty if + * there were no changes during the requested interval. - The `Before` snapshot timestamp value of the oldest change + * can be outside of the specified time interval. + * + * @return the changes value. + */ + List changes(); + + /** + * Gets the skipToken property: Skip token that encodes the skip information while executing the current request. + * + * @return the skipToken value. + */ + Object skipToken(); + + /** + * Gets the inner com.azure.resourcemanager.resourcegraph.fluent.models.ResourceChangeListInner object. + * + * @return the inner object. + */ + ResourceChangeListInner innerModel(); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangesRequestParameters.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangesRequestParameters.java new file mode 100644 index 000000000000..3c958bc81a17 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangesRequestParameters.java @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The parameters for a specific changes request. */ +@Fluent +public final class ResourceChangesRequestParameters { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceChangesRequestParameters.class); + + /* + * Specifies the resource for a changes request. + */ + @JsonProperty(value = "resourceId", required = true) + private String resourceId; + + /* + * Specifies the date and time interval for a changes request. + */ + @JsonProperty(value = "interval", required = true) + private DateTimeInterval interval; + + /* + * Acts as the continuation token for paged responses. + */ + @JsonProperty(value = "$skipToken") + private String skipToken; + + /* + * The maximum number of changes the client can accept in a paged response. + */ + @JsonProperty(value = "$top") + private Integer top; + + /* + * The flag if set to true will fetch property changes + */ + @JsonProperty(value = "fetchPropertyChanges") + private Boolean fetchPropertyChanges; + + /** + * Get the resourceId property: Specifies the resource for a changes request. + * + * @return the resourceId value. + */ + public String resourceId() { + return this.resourceId; + } + + /** + * Set the resourceId property: Specifies the resource for a changes request. + * + * @param resourceId the resourceId value to set. + * @return the ResourceChangesRequestParameters object itself. + */ + public ResourceChangesRequestParameters withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * Get the interval property: Specifies the date and time interval for a changes request. + * + * @return the interval value. + */ + public DateTimeInterval interval() { + return this.interval; + } + + /** + * Set the interval property: Specifies the date and time interval for a changes request. + * + * @param interval the interval value to set. + * @return the ResourceChangesRequestParameters object itself. + */ + public ResourceChangesRequestParameters withInterval(DateTimeInterval interval) { + this.interval = interval; + return this; + } + + /** + * Get the skipToken property: Acts as the continuation token for paged responses. + * + * @return the skipToken value. + */ + public String skipToken() { + return this.skipToken; + } + + /** + * Set the skipToken property: Acts as the continuation token for paged responses. + * + * @param skipToken the skipToken value to set. + * @return the ResourceChangesRequestParameters object itself. + */ + public ResourceChangesRequestParameters withSkipToken(String skipToken) { + this.skipToken = skipToken; + return this; + } + + /** + * Get the top property: The maximum number of changes the client can accept in a paged response. + * + * @return the top value. + */ + public Integer top() { + return this.top; + } + + /** + * Set the top property: The maximum number of changes the client can accept in a paged response. + * + * @param top the top value to set. + * @return the ResourceChangesRequestParameters object itself. + */ + public ResourceChangesRequestParameters withTop(Integer top) { + this.top = top; + return this; + } + + /** + * Get the fetchPropertyChanges property: The flag if set to true will fetch property changes. + * + * @return the fetchPropertyChanges value. + */ + public Boolean fetchPropertyChanges() { + return this.fetchPropertyChanges; + } + + /** + * Set the fetchPropertyChanges property: The flag if set to true will fetch property changes. + * + * @param fetchPropertyChanges the fetchPropertyChanges value to set. + * @return the ResourceChangesRequestParameters object itself. + */ + public ResourceChangesRequestParameters withFetchPropertyChanges(Boolean fetchPropertyChanges) { + this.fetchPropertyChanges = fetchPropertyChanges; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (resourceId() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property resourceId in model ResourceChangesRequestParameters")); + } + if (interval() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property interval in model ResourceChangesRequestParameters")); + } else { + interval().validate(); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangesRequestParametersInterval.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangesRequestParametersInterval.java new file mode 100644 index 000000000000..fd93e3a6b14a --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceChangesRequestParametersInterval.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Immutable; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import java.time.OffsetDateTime; + +/** Specifies the date and time interval for a changes request. */ +@Immutable +public final class ResourceChangesRequestParametersInterval extends DateTimeInterval { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceChangesRequestParametersInterval.class); + + /** {@inheritDoc} */ + @Override + public ResourceChangesRequestParametersInterval withStart(OffsetDateTime start) { + super.withStart(start); + return this; + } + + /** {@inheritDoc} */ + @Override + public ResourceChangesRequestParametersInterval withEnd(OffsetDateTime end) { + super.withEnd(end); + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + @Override + public void validate() { + super.validate(); + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourcePropertyChange.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourcePropertyChange.java new file mode 100644 index 000000000000..1f56ba56ae71 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourcePropertyChange.java @@ -0,0 +1,172 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** The resource property change. */ +@Fluent +public final class ResourcePropertyChange { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourcePropertyChange.class); + + /* + * The property name + */ + @JsonProperty(value = "propertyName", required = true) + private String propertyName; + + /* + * The property value in before snapshot + */ + @JsonProperty(value = "beforeValue") + private String beforeValue; + + /* + * The property value in after snapshot + */ + @JsonProperty(value = "afterValue") + private String afterValue; + + /* + * The change category. + */ + @JsonProperty(value = "changeCategory", required = true) + private ChangeCategory changeCategory; + + /* + * The property change Type + */ + @JsonProperty(value = "propertyChangeType", required = true) + private PropertyChangeType propertyChangeType; + + /** + * Get the propertyName property: The property name. + * + * @return the propertyName value. + */ + public String propertyName() { + return this.propertyName; + } + + /** + * Set the propertyName property: The property name. + * + * @param propertyName the propertyName value to set. + * @return the ResourcePropertyChange object itself. + */ + public ResourcePropertyChange withPropertyName(String propertyName) { + this.propertyName = propertyName; + return this; + } + + /** + * Get the beforeValue property: The property value in before snapshot. + * + * @return the beforeValue value. + */ + public String beforeValue() { + return this.beforeValue; + } + + /** + * Set the beforeValue property: The property value in before snapshot. + * + * @param beforeValue the beforeValue value to set. + * @return the ResourcePropertyChange object itself. + */ + public ResourcePropertyChange withBeforeValue(String beforeValue) { + this.beforeValue = beforeValue; + return this; + } + + /** + * Get the afterValue property: The property value in after snapshot. + * + * @return the afterValue value. + */ + public String afterValue() { + return this.afterValue; + } + + /** + * Set the afterValue property: The property value in after snapshot. + * + * @param afterValue the afterValue value to set. + * @return the ResourcePropertyChange object itself. + */ + public ResourcePropertyChange withAfterValue(String afterValue) { + this.afterValue = afterValue; + return this; + } + + /** + * Get the changeCategory property: The change category. + * + * @return the changeCategory value. + */ + public ChangeCategory changeCategory() { + return this.changeCategory; + } + + /** + * Set the changeCategory property: The change category. + * + * @param changeCategory the changeCategory value to set. + * @return the ResourcePropertyChange object itself. + */ + public ResourcePropertyChange withChangeCategory(ChangeCategory changeCategory) { + this.changeCategory = changeCategory; + return this; + } + + /** + * Get the propertyChangeType property: The property change Type. + * + * @return the propertyChangeType value. + */ + public PropertyChangeType propertyChangeType() { + return this.propertyChangeType; + } + + /** + * Set the propertyChangeType property: The property change Type. + * + * @param propertyChangeType the propertyChangeType value to set. + * @return the ResourcePropertyChange object itself. + */ + public ResourcePropertyChange withPropertyChangeType(PropertyChangeType propertyChangeType) { + this.propertyChangeType = propertyChangeType; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (propertyName() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property propertyName in model ResourcePropertyChange")); + } + if (changeCategory() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property changeCategory in model ResourcePropertyChange")); + } + if (propertyChangeType() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException( + "Missing required property propertyChangeType in model ResourcePropertyChange")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceProviders.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceProviders.java new file mode 100644 index 000000000000..d9791ef58dde --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceProviders.java @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.http.rest.Response; +import com.azure.core.util.Context; + +/** Resource collection API of ResourceProviders. */ +public interface ResourceProviders { + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + QueryResponse resources(QueryRequest query); + + /** + * Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request. + * + * @param query Request specifying query and its options. + * @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 query result. + */ + Response resourcesWithResponse(QueryRequest query, Context context); + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + ResourceChangeList resourceChanges(ResourceChangesRequestParameters parameters); + + /** + * List changes to a resource for a given time interval. + * + * @param parameters the parameters for this request for changes. + * @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 changes associated with a resource over a specific time interval. + */ + Response resourceChangesWithResponse( + ResourceChangesRequestParameters parameters, Context context); + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + ResourceChangeData resourceChangeDetails(ResourceChangeDetailsRequestParameters parameters); + + /** + * Get resource change details. + * + * @param parameters The parameters for this request for resource change details. + * @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 resource change details. + */ + Response resourceChangeDetailsWithResponse( + ResourceChangeDetailsRequestParameters parameters, Context context); +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceSnapshotData.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceSnapshotData.java new file mode 100644 index 000000000000..e65d59df3fd6 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResourceSnapshotData.java @@ -0,0 +1,94 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.azure.core.annotation.Fluent; +import com.azure.core.util.logging.ClientLogger; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.time.OffsetDateTime; + +/** Data on a specific resource snapshot. */ +@Fluent +public class ResourceSnapshotData { + @JsonIgnore private final ClientLogger logger = new ClientLogger(ResourceSnapshotData.class); + + /* + * The time when the snapshot was created. + * The snapshot timestamp provides an approximation as to when a + * modification to a resource was detected. There can be a difference + * between the actual modification time and the detection time. This is + * due to differences in how operations that modify a resource are + * processed, versus how operation that record resource snapshots are + * processed. + */ + @JsonProperty(value = "timestamp", required = true) + private OffsetDateTime timestamp; + + /* + * The resource snapshot content (in resourceChangeDetails response only). + */ + @JsonProperty(value = "content") + private Object content; + + /** + * Get the timestamp property: The time when the snapshot was created. The snapshot timestamp provides an + * approximation as to when a modification to a resource was detected. There can be a difference between the actual + * modification time and the detection time. This is due to differences in how operations that modify a resource are + * processed, versus how operation that record resource snapshots are processed. + * + * @return the timestamp value. + */ + public OffsetDateTime timestamp() { + return this.timestamp; + } + + /** + * Set the timestamp property: The time when the snapshot was created. The snapshot timestamp provides an + * approximation as to when a modification to a resource was detected. There can be a difference between the actual + * modification time and the detection time. This is due to differences in how operations that modify a resource are + * processed, versus how operation that record resource snapshots are processed. + * + * @param timestamp the timestamp value to set. + * @return the ResourceSnapshotData object itself. + */ + public ResourceSnapshotData withTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get the content property: The resource snapshot content (in resourceChangeDetails response only). + * + * @return the content value. + */ + public Object content() { + return this.content; + } + + /** + * Set the content property: The resource snapshot content (in resourceChangeDetails response only). + * + * @param content the content value to set. + * @return the ResourceSnapshotData object itself. + */ + public ResourceSnapshotData withContent(Object content) { + this.content = content; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (timestamp() == null) { + throw logger + .logExceptionAsError( + new IllegalArgumentException("Missing required property timestamp in model ResourceSnapshotData")); + } + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResultFormat.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResultFormat.java new file mode 100644 index 000000000000..1c4046e89b81 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResultFormat.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for ResultFormat. */ +public enum ResultFormat { + /** Enum value table. */ + TABLE("table"), + + /** Enum value objectArray. */ + OBJECT_ARRAY("objectArray"); + + /** The actual serialized value for a ResultFormat instance. */ + private final String value; + + ResultFormat(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ResultFormat instance. + * + * @param value the serialized value to parse. + * @return the parsed ResultFormat object, or null if unable to parse. + */ + @JsonCreator + public static ResultFormat fromString(String value) { + ResultFormat[] items = ResultFormat.values(); + for (ResultFormat item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResultTruncated.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResultTruncated.java new file mode 100644 index 000000000000..ff78599437fc --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/ResultTruncated.java @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.resourcemanager.resourcegraph.models; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Defines values for ResultTruncated. */ +public enum ResultTruncated { + /** Enum value true. */ + TRUE("true"), + + /** Enum value false. */ + FALSE("false"); + + /** The actual serialized value for a ResultTruncated instance. */ + private final String value; + + ResultTruncated(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a ResultTruncated instance. + * + * @param value the serialized value to parse. + * @return the parsed ResultTruncated object, or null if unable to parse. + */ + @JsonCreator + public static ResultTruncated fromString(String value) { + ResultTruncated[] items = ResultTruncated.values(); + for (ResultTruncated item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @JsonValue + @Override + public String toString() { + return this.value; + } +} diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/package-info.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/models/package-info.java new file mode 100644 index 000000000000..af43513038cd --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/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 ResourceGraphClient. Azure Resource Graph API Reference. */ +package com.azure.resourcemanager.resourcegraph.models; diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/package-info.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/package-info.java new file mode 100644 index 000000000000..269cfb8e3444 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/com/azure/resourcemanager/resourcegraph/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 ResourceGraphClient. Azure Resource Graph API Reference. */ +package com.azure.resourcemanager.resourcegraph; diff --git a/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/module-info.java b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/src/main/java/module-info.java new file mode 100644 index 000000000000..9a3906b837b5 --- /dev/null +++ b/sdk/resourcegraph/azure-resourcemanager-resourcegraph/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.resourcegraph { + requires transitive com.azure.core.management; + + exports com.azure.resourcemanager.resourcegraph; + exports com.azure.resourcemanager.resourcegraph.fluent; + exports com.azure.resourcemanager.resourcegraph.fluent.models; + exports com.azure.resourcemanager.resourcegraph.models; + + opens com.azure.resourcemanager.resourcegraph.fluent.models to + com.azure.core, + com.fasterxml.jackson.databind; + opens com.azure.resourcemanager.resourcegraph.models to + com.azure.core, + com.fasterxml.jackson.databind; +} diff --git a/sdk/resourcegraph/ci.yml b/sdk/resourcegraph/ci.yml new file mode 100644 index 000000000000..ef831a857b10 --- /dev/null +++ b/sdk/resourcegraph/ci.yml @@ -0,0 +1,31 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - hotfix/* + - release/* + paths: + include: + - sdk/resourcegraph/ + +pr: + branches: + include: + - master + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcegraph/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: resourcegraph + Artifacts: + - name: azure-resourcemanager-resourcegraph + groupId: com.azure.resourcemanager + safeName: azureresourcemanagerresourcegraph diff --git a/sdk/resourcegraph/pom.xml b/sdk/resourcegraph/pom.xml new file mode 100644 index 000000000000..4406c6b05beb --- /dev/null +++ b/sdk/resourcegraph/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + com.azure + azure-resourcegraph-service + pom + 1.0.0 + + azure-resourcemanager-resourcegraph + +