Skip to content

Commit

Permalink
mgmt, resourcegraph track1 (Azure#19943)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft authored Mar 19, 2021
1 parent 1b40bc6 commit f25746c
Show file tree
Hide file tree
Showing 13 changed files with 441 additions and 120 deletions.
2 changes: 1 addition & 1 deletion eng/mgmt/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const maxParallelism = parseInt(args['parallel'], 10) || os.cpus().length;
var specRoot = args['spec-root'] || defaultSpecRoot;
var sdkRoot = path.join(process.cwd(), '../..')
var projects = args['projects'];
var autoRestVersion = 'preview'; // default
var autoRestVersion = '2.0.4417'; // default
if (args['autorest'] !== undefined) {
autoRestVersion = args['autorest'];
}
Expand Down
8 changes: 5 additions & 3 deletions sdk/resourcegraph/mgmt-v2019_04_01/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<parent>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-arm-parent</artifactId>
<version>1.2.0</version>
<relativePath>../../parents/azure-arm-parent</relativePath>
<version>1.3.2</version>
<relativePath>../../parents/azure-arm-parent/pom.xml</relativePath>
</parent>
<artifactId>azure-mgmt-resourcegraph</artifactId>
<version>1.0.0-beta-1</version>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Microsoft Azure SDK for ResourceGraph Management</name>
<description>This package contains Microsoft ResourceGraph Management SDK.</description>
Expand Down Expand Up @@ -71,6 +71,8 @@
<artifactId>azure-arm-client-runtime</artifactId>
<type>test-jar</type>
<scope>test</scope>
<!--Below version for test jar needs to be removed, this will be done as part of v1-runtime 1.6.7-->
<version>1.6.5</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* 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")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType", defaultImpl = Facet.class)
@JsonTypeName("Facet")
@JsonSubTypes({
@JsonSubTypes.Type(name = "FacetResult", value = FacetResult.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* A facet whose execution resulted in an error.
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType", defaultImpl = FacetError.class)
@JsonTypeName("FacetError")
public class FacetError extends Facet {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Successfully executed facet containing additional statistics on the response
* of a query.
*/
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType")
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "resultType", defaultImpl = FacetResult.class)
@JsonTypeName("FacetResult")
public class FacetResult extends Facet {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.management.resourcegraph.v2019_04_01;

import com.microsoft.azure.arm.model.HasInner;
import com.microsoft.azure.arm.resources.models.HasManager;
import com.microsoft.azure.management.resourcegraph.v2019_04_01.implementation.ResourceGraphManager;
import com.microsoft.azure.management.resourcegraph.v2019_04_01.implementation.QueryResponseInner;
import java.util.List;

/**
* Type representing QueryResponse.
*/
public interface QueryResponse extends HasInner<QueryResponseInner>, HasManager<ResourceGraphManager> {
/**
* @return the count value.
*/
long count();

/**
* @return the data value.
*/
Object data();

/**
* @return the facets value.
*/
List<Facet> facets();

/**
* @return the resultTruncated value.
*/
ResultTruncated resultTruncated();

/**
* @return the skipToken value.
*/
String skipToken();

/**
* @return the totalRecords value.
*/
long totalRecords();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.management.resourcegraph.v2019_04_01;

import rx.Observable;
import com.microsoft.azure.management.resourcegraph.v2019_04_01.implementation.ResourceProvidersInner;
import com.microsoft.azure.arm.model.HasInner;

/**
* Type representing ResourceProviders.
*/
public interface ResourceProviders extends HasInner<ResourceProvidersInner> {
/**
* 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
* @return the observable for the request
*/
Observable<QueryResponse> resourcesAsync(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.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the response
*/
QueryResponse resources(QueryRequest query);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
*/

package com.microsoft.azure.management.resourcegraph.v2019_04_01.implementation;

import com.microsoft.azure.management.resourcegraph.v2019_04_01.QueryResponse;
import com.microsoft.azure.arm.model.implementation.WrapperImpl;
import java.util.List;
import com.microsoft.azure.management.resourcegraph.v2019_04_01.Facet;
import com.microsoft.azure.management.resourcegraph.v2019_04_01.ResultTruncated;

class QueryResponseImpl extends WrapperImpl<QueryResponseInner> implements QueryResponse {
private final ResourceGraphManager manager;
QueryResponseImpl(QueryResponseInner inner, ResourceGraphManager manager) {
super(inner);
this.manager = manager;
}

@Override
public ResourceGraphManager manager() {
return this.manager;
}

@Override
public long count() {
return this.inner().count();
}

@Override
public Object data() {
return this.inner().data();
}

@Override
public List<Facet> facets() {
return this.inner().facets();
}

@Override
public ResultTruncated resultTruncated() {
return this.inner().resultTruncated();
}

@Override
public String skipToken() {
return this.inner().skipToken();
}

@Override
public long totalRecords() {
return this.inner().totalRecords();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,15 @@

package com.microsoft.azure.management.resourcegraph.v2019_04_01.implementation;

import com.google.common.reflect.TypeToken;
import com.microsoft.azure.AzureClient;
import com.microsoft.azure.AzureServiceClient;
import com.microsoft.azure.management.resourcegraph.v2019_04_01.ErrorResponseException;
import com.microsoft.azure.management.resourcegraph.v2019_04_01.QueryRequest;
import com.microsoft.rest.credentials.ServiceClientCredentials;
import com.microsoft.rest.RestClient;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceFuture;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.Validator;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;

/**
* Initializes a new instance of the ResourceGraphClientImpl class.
*/
public class ResourceGraphClientImpl extends AzureServiceClient {
/** The Retrofit service to perform REST calls. */
private ResourceGraphClientService service;
/** the {@link AzureClient} used for long running operations. */
private AzureClient azureClient;

Expand Down Expand Up @@ -128,6 +109,19 @@ public ResourceGraphClientImpl withGenerateClientRequestId(boolean generateClien
return this;
}

/**
* The ResourceProvidersInner object to access its operations.
*/
private ResourceProvidersInner resourceProviders;

/**
* Gets the ResourceProvidersInner object to access its operations.
* @return the ResourceProvidersInner object.
*/
public ResourceProvidersInner resourceProviders() {
return this.resourceProviders;
}

/**
* The OperationsInner object to access its operations.
*/
Expand Down Expand Up @@ -176,9 +170,9 @@ protected void initialize() {
this.acceptLanguage = "en-US";
this.longRunningOperationRetryTimeout = 30;
this.generateClientRequestId = true;
this.resourceProviders = new ResourceProvidersInner(restClient().retrofit(), this);
this.operations = new OperationsInner(restClient().retrofit(), this);
this.azureClient = new AzureClient(this);
initializeService();
}

/**
Expand All @@ -190,97 +184,4 @@ protected void initialize() {
public String userAgent() {
return String.format("%s (%s, %s, auto-generated)", super.userAgent(), "ResourceGraphClient", "2019-04-01");
}

private void initializeService() {
service = restClient().retrofit().create(ResourceGraphClientService.class);
}

/**
* The interface defining all the services for ResourceGraphClient to be
* used by Retrofit to perform actually REST calls.
*/
interface ResourceGraphClientService {
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.resourcegraph.v2019_04_01.ResourceGraphClient resources" })
@POST("providers/Microsoft.ResourceGraph/resources")
Observable<Response<ResponseBody>> resources(@Query("api-version") String apiVersion, @Body QueryRequest query, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);

}

/**
* 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 ErrorResponseException thrown if the request is rejected by server
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent
* @return the QueryResponseInner object if successful.
*/
public QueryResponseInner resources(QueryRequest query) {
return resourcesWithServiceResponseAsync(query).toBlocking().single().body();
}

/**
* Queries the resources managed by Azure Resource Manager for all subscriptions specified in the request.
*
* @param query Request specifying query and its options.
* @param serviceCallback the async ServiceCallback to handle successful and failed responses.
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceFuture} object
*/
public ServiceFuture<QueryResponseInner> resourcesAsync(QueryRequest query, final ServiceCallback<QueryResponseInner> serviceCallback) {
return ServiceFuture.fromResponse(resourcesWithServiceResponseAsync(query), serviceCallback);
}

/**
* 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
* @return the observable to the QueryResponseInner object
*/
public Observable<QueryResponseInner> resourcesAsync(QueryRequest query) {
return resourcesWithServiceResponseAsync(query).map(new Func1<ServiceResponse<QueryResponseInner>, QueryResponseInner>() {
@Override
public QueryResponseInner call(ServiceResponse<QueryResponseInner> response) {
return response.body();
}
});
}

/**
* 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
* @return the observable to the QueryResponseInner object
*/
public Observable<ServiceResponse<QueryResponseInner>> resourcesWithServiceResponseAsync(QueryRequest query) {
if (this.apiVersion() == null) {
throw new IllegalArgumentException("Parameter this.apiVersion() is required and cannot be null.");
}
if (query == null) {
throw new IllegalArgumentException("Parameter query is required and cannot be null.");
}
Validator.validate(query);
return service.resources(this.apiVersion(), query, this.acceptLanguage(), this.userAgent())
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<QueryResponseInner>>>() {
@Override
public Observable<ServiceResponse<QueryResponseInner>> call(Response<ResponseBody> response) {
try {
ServiceResponse<QueryResponseInner> clientResponse = resourcesDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}

private ServiceResponse<QueryResponseInner> resourcesDelegate(Response<ResponseBody> response) throws ErrorResponseException, IOException, IllegalArgumentException {
return this.restClient().responseBuilderFactory().<QueryResponseInner, ErrorResponseException>newInstance(this.serializerAdapter())
.register(200, new TypeToken<QueryResponseInner>() { }.getType())
.registerError(ErrorResponseException.class)
.build(response);
}

}
Loading

0 comments on commit f25746c

Please sign in to comment.