Skip to content

Commit

Permalink
Initial GA work for digital twins (Azure#16039)
Browse files Browse the repository at this point in the history
GA service swagger comes with new optional parameters for all service requests. Thankfully the swagger also conveniently groups them together with existing options so that we can directly use the generated options objects in our CL APIs (except for a few cases)
  • Loading branch information
timtay-microsoft authored Oct 7, 2020
1 parent aced874 commit e0da820
Show file tree
Hide file tree
Showing 143 changed files with 11,922 additions and 9,806 deletions.
7 changes: 4 additions & 3 deletions sdk/digitaltwins/azure-digitaltwins-core/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Run `generate.ps1` in this directory to generate the code.

``` yaml
#When generating from the official specifications repository
input-file: 2020-10-31/digitaltwins.json
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/14fb40342c19f8b483e132038f8424ee62b745d9/specification/digitaltwins/data-plane/Microsoft.DigitalTwins/stable/2020-10-31/digitaltwins.json

#When generating from the local copy:
#input-file: 2020-05-31-preview/digitaltwins.json
#if you want to generate using local swagger copy:
#input-file: $(this-folder)/swagger/2020-`0-31/digitaltwins.json

output-folder: "./"
license-header: MICROSOFT_MIT_SMALL
Expand All @@ -40,4 +40,5 @@ java:
context-client-method-parameter: true
custom-types-subpackage: models
required-fields-as-ctor-args: true
custom-types: DigitalTwinModelsAddOptions,DigitalTwinModelsDeleteOptions,DigitalTwinModelsGetByIdOptions,DigitalTwinModelsUpdateOptions,DigitalTwinsAddOptions,DigitalTwinsAddRelationshipOptions,DigitalTwinsDeleteOptions,DigitalTwinsDeleteRelationshipOptions,DigitalTwinsGetByIdOptions,DigitalTwinsGetComponentOptions,DigitalTwinsGetRelationshipByIdOptions,DigitalTwinsListIncomingRelationshipsOptions,DigitalTwinsListRelationshipsOptions,DigitalTwinsUpdateComponentOptions,DigitalTwinsUpdateOptions,DigitalTwinsUpdateRelationshipOptions,EventRoutesAddOptions,EventRoutesDeleteOptions,EventRoutesGetByIdOptions,EventRoutesListOptions,QueryTwinsOptions
```

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public EventRoutesImpl getEventRoutes() {
this.httpPipeline = httpPipeline;
this.serializerAdapter = serializerAdapter;
this.host = host;
this.apiVersion = "2020-05-31-preview";
this.apiVersion = "2020-10-31";
this.digitalTwinModels = new DigitalTwinModelsImpl(this);
this.queries = new QueriesImpl(this);
this.digitalTwins = new DigitalTwinsImpl(this);
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
import com.azure.digitaltwins.core.implementation.models.ErrorResponseException;
import com.azure.digitaltwins.core.implementation.models.EventRoute;
import com.azure.digitaltwins.core.implementation.models.EventRouteCollection;
import com.azure.digitaltwins.core.implementation.models.EventRoutesListOptions;
import com.azure.digitaltwins.core.models.EventRoutesAddOptions;
import com.azure.digitaltwins.core.models.EventRoutesDeleteOptions;
import com.azure.digitaltwins.core.models.EventRoutesGetByIdOptions;
import com.azure.digitaltwins.core.models.EventRoutesListOptions;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in EventRoutes. */
Expand Down Expand Up @@ -60,7 +63,9 @@ private interface EventRoutesService {
@UnexpectedResponseExceptionType(ErrorResponseException.class)
Mono<Response<EventRouteCollection>> list(
@HostParam("$host") String host,
@HeaderParam("x-ms-max-item-count") Integer maxItemCount,
@HeaderParam("traceparent") String traceparent,
@HeaderParam("tracestate") String tracestate,
@HeaderParam("max-items-per-page") Integer maxItemsPerPage,
@QueryParam("api-version") String apiVersion,
Context context);

Expand All @@ -69,6 +74,8 @@ Mono<Response<EventRouteCollection>> list(
@UnexpectedResponseExceptionType(ErrorResponseException.class)
Mono<Response<EventRoute>> getById(
@HostParam("$host") String host,
@HeaderParam("traceparent") String traceparent,
@HeaderParam("tracestate") String tracestate,
@PathParam("id") String id,
@QueryParam("api-version") String apiVersion,
Context context);
Expand All @@ -78,6 +85,8 @@ Mono<Response<EventRoute>> getById(
@UnexpectedResponseExceptionType(ErrorResponseException.class)
Mono<Response<Void>> add(
@HostParam("$host") String host,
@HeaderParam("traceparent") String traceparent,
@HeaderParam("tracestate") String tracestate,
@PathParam("id") String id,
@QueryParam("api-version") String apiVersion,
@BodyParam("application/json") EventRoute eventRoute,
Expand All @@ -88,6 +97,8 @@ Mono<Response<Void>> add(
@UnexpectedResponseExceptionType(ErrorResponseException.class)
Mono<Response<Void>> delete(
@HostParam("$host") String host,
@HeaderParam("traceparent") String traceparent,
@HeaderParam("tracestate") String tracestate,
@PathParam("id") String id,
@QueryParam("api-version") String apiVersion,
Context context);
Expand All @@ -98,12 +109,14 @@ Mono<Response<Void>> delete(
Mono<Response<EventRouteCollection>> listNext(
@PathParam(value = "nextLink", encoded = true) String nextLink,
@HostParam("$host") String host,
@HeaderParam("x-ms-max-item-count") Integer maxItemCount,
@HeaderParam("traceparent") String traceparent,
@HeaderParam("tracestate") String tracestate,
@HeaderParam("max-items-per-page") Integer maxItemsPerPage,
Context context);
}

/**
* Retrieves all event routes. Status codes: 200 (OK): Success. 400 (Bad Request): The request is invalid.
* Retrieves all event routes. Status codes: * 200 OK.
*
* @param eventRoutesListOptions Parameter group.
* @param context The context to associate with this operation.
Expand All @@ -122,12 +135,28 @@ public Mono<PagedResponse<EventRoute>> listSinglePageAsync(
if (eventRoutesListOptions != null) {
eventRoutesListOptions.validate();
}
Integer maxItemCountInternal = null;
String traceparentInternal = null;
if (eventRoutesListOptions != null) {
maxItemCountInternal = eventRoutesListOptions.getMaxItemCount();
traceparentInternal = eventRoutesListOptions.getTraceparent();
}
Integer maxItemCount = maxItemCountInternal;
return service.list(this.client.getHost(), maxItemCount, this.client.getApiVersion(), context)
String traceparent = traceparentInternal;
String tracestateInternal = null;
if (eventRoutesListOptions != null) {
tracestateInternal = eventRoutesListOptions.getTracestate();
}
String tracestate = tracestateInternal;
Integer maxItemsPerPageInternal = null;
if (eventRoutesListOptions != null) {
maxItemsPerPageInternal = eventRoutesListOptions.getMaxItemsPerPage();
}
Integer maxItemsPerPage = maxItemsPerPageInternal;
return service.list(
this.client.getHost(),
traceparent,
tracestate,
maxItemsPerPage,
this.client.getApiVersion(),
context)
.map(
res ->
new PagedResponseBase<>(
Expand All @@ -140,76 +169,126 @@ public Mono<PagedResponse<EventRoute>> listSinglePageAsync(
}

/**
* Retrieves an event route. Status codes: 200 (OK): Success. 404 (Not Found): There is no event route with the
* provided id.
* Retrieves an event route. Status codes: * 200 OK * 404 Not Found * EventRouteNotFound - The event route was not
* found.
*
* @param id The id for an event route. The id is unique within event routes and case sensitive.
* @param eventRoutesGetByIdOptions Parameter group.
* @param context The context to associate with this operation.
* @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 a route which directs notification and telemetry events to an endpoint.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<EventRoute>> getByIdWithResponseAsync(String id, Context context) {
public Mono<Response<EventRoute>> getByIdWithResponseAsync(
String id, EventRoutesGetByIdOptions eventRoutesGetByIdOptions, Context context) {
if (this.client.getHost() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null."));
}
if (id == null) {
return Mono.error(new IllegalArgumentException("Parameter id is required and cannot be null."));
}
return service.getById(this.client.getHost(), id, this.client.getApiVersion(), context);
if (eventRoutesGetByIdOptions != null) {
eventRoutesGetByIdOptions.validate();
}
String traceparentInternal = null;
if (eventRoutesGetByIdOptions != null) {
traceparentInternal = eventRoutesGetByIdOptions.getTraceparent();
}
String traceparent = traceparentInternal;
String tracestateInternal = null;
if (eventRoutesGetByIdOptions != null) {
tracestateInternal = eventRoutesGetByIdOptions.getTracestate();
}
String tracestate = tracestateInternal;
return service.getById(
this.client.getHost(), traceparent, tracestate, id, this.client.getApiVersion(), context);
}

/**
* Adds or replaces an event route. Status codes: 200 (OK): Success. 400 (Bad Request): The request is invalid.
* Adds or replaces an event route. Status codes: * 204 No Content * 400 Bad Request * EventRouteEndpointInvalid -
* The endpoint provided does not exist or is not active. * EventRouteFilterInvalid - The event route filter is
* invalid. * EventRouteIdInvalid - The event route id is invalid. * LimitExceeded - The maximum number of event
* routes allowed has been reached.
*
* @param id The id for an event route. The id is unique within event routes and case sensitive.
* @param eventRoute A route which directs notification and telemetry events to an endpoint. Endpoints are a
* destination outside of Azure Digital Twins such as an EventHub.
* @param eventRoutesAddOptions Parameter group.
* @param context The context to associate with this operation.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> addWithResponseAsync(String id, EventRoute eventRoute, Context context) {
public Mono<Response<Void>> addWithResponseAsync(
String id, EventRoute eventRoute, EventRoutesAddOptions eventRoutesAddOptions, Context context) {
if (this.client.getHost() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null."));
}
if (id == null) {
return Mono.error(new IllegalArgumentException("Parameter id is required and cannot be null."));
}
if (eventRoutesAddOptions != null) {
eventRoutesAddOptions.validate();
}
if (eventRoute != null) {
eventRoute.validate();
}
return service.add(this.client.getHost(), id, this.client.getApiVersion(), eventRoute, context);
String traceparentInternal = null;
if (eventRoutesAddOptions != null) {
traceparentInternal = eventRoutesAddOptions.getTraceparent();
}
String traceparent = traceparentInternal;
String tracestateInternal = null;
if (eventRoutesAddOptions != null) {
tracestateInternal = eventRoutesAddOptions.getTracestate();
}
String tracestate = tracestateInternal;
return service.add(
this.client.getHost(), traceparent, tracestate, id, this.client.getApiVersion(), eventRoute, context);
}

/**
* Deletes an event route. Status codes: 200 (OK): Success. 404 (Not Found): There is no event route with the
* provided id.
* Deletes an event route. Status codes: * 204 No Content * 404 Not Found * EventRouteNotFound - The event route was
* not found.
*
* @param id The id for an event route. The id is unique within event routes and case sensitive.
* @param eventRoutesDeleteOptions Parameter group.
* @param context The context to associate with this operation.
* @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 completion.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Void>> deleteWithResponseAsync(String id, Context context) {
public Mono<Response<Void>> deleteWithResponseAsync(
String id, EventRoutesDeleteOptions eventRoutesDeleteOptions, Context context) {
if (this.client.getHost() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null."));
}
if (id == null) {
return Mono.error(new IllegalArgumentException("Parameter id is required and cannot be null."));
}
return service.delete(this.client.getHost(), id, this.client.getApiVersion(), context);
if (eventRoutesDeleteOptions != null) {
eventRoutesDeleteOptions.validate();
}
String traceparentInternal = null;
if (eventRoutesDeleteOptions != null) {
traceparentInternal = eventRoutesDeleteOptions.getTraceparent();
}
String traceparent = traceparentInternal;
String tracestateInternal = null;
if (eventRoutesDeleteOptions != null) {
tracestateInternal = eventRoutesDeleteOptions.getTracestate();
}
String tracestate = tracestateInternal;
return service.delete(this.client.getHost(), traceparent, tracestate, id, this.client.getApiVersion(), context);
}

/**
Expand All @@ -236,12 +315,22 @@ public Mono<PagedResponse<EventRoute>> listNextSinglePageAsync(
if (eventRoutesListOptions != null) {
eventRoutesListOptions.validate();
}
Integer maxItemCountInternal = null;
String traceparentInternal = null;
if (eventRoutesListOptions != null) {
traceparentInternal = eventRoutesListOptions.getTraceparent();
}
String traceparent = traceparentInternal;
String tracestateInternal = null;
if (eventRoutesListOptions != null) {
tracestateInternal = eventRoutesListOptions.getTracestate();
}
String tracestate = tracestateInternal;
Integer maxItemsPerPageInternal = null;
if (eventRoutesListOptions != null) {
maxItemCountInternal = eventRoutesListOptions.getMaxItemCount();
maxItemsPerPageInternal = eventRoutesListOptions.getMaxItemsPerPage();
}
Integer maxItemCount = maxItemCountInternal;
return service.listNext(nextLink, this.client.getHost(), maxItemCount, context)
Integer maxItemsPerPage = maxItemsPerPageInternal;
return service.listNext(nextLink, this.client.getHost(), traceparent, tracestate, maxItemsPerPage, context)
.map(
res ->
new PagedResponseBase<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.Post;
Expand All @@ -19,6 +20,7 @@
import com.azure.digitaltwins.core.implementation.models.ErrorResponseException;
import com.azure.digitaltwins.core.implementation.models.QueriesQueryTwinsResponse;
import com.azure.digitaltwins.core.implementation.models.QuerySpecification;
import com.azure.digitaltwins.core.models.QueryTwinsOptions;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in Queries. */
Expand Down Expand Up @@ -51,17 +53,22 @@ private interface QueriesService {
@UnexpectedResponseExceptionType(ErrorResponseException.class)
Mono<QueriesQueryTwinsResponse> queryTwins(
@HostParam("$host") String host,
@HeaderParam("traceparent") String traceparent,
@HeaderParam("tracestate") String tracestate,
@HeaderParam("max-items-per-page") Integer maxItemsPerPage,
@QueryParam("api-version") String apiVersion,
@BodyParam("application/json") QuerySpecification querySpecification,
Context context);
}

/**
* Executes a query that allows traversing relationships and filtering by property values. Status codes: 200 (OK):
* Success. 400 (Bad Request): The request is invalid.
* Executes a query that allows traversing relationships and filtering by property values. Status codes: * 200 OK *
* 400 Bad Request * BadRequest - The continuation token is invalid. * SqlQueryError - The query contains some
* errors. * 429 Too Many Requests * QuotaReachedError - The maximum query rate limit has been reached.
*
* @param querySpecification A query specification containing either a query statement or a continuation token from
* a previous query result.
* @param queryTwinsOptions Parameter group.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws ErrorResponseException thrown if the request is rejected by server.
Expand All @@ -70,7 +77,7 @@ Mono<QueriesQueryTwinsResponse> queryTwins(
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<QueriesQueryTwinsResponse> queryTwinsWithResponseAsync(
QuerySpecification querySpecification, Context context) {
QuerySpecification querySpecification, QueryTwinsOptions queryTwinsOptions, Context context) {
if (this.client.getHost() == null) {
return Mono.error(
new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null."));
Expand All @@ -81,6 +88,31 @@ public Mono<QueriesQueryTwinsResponse> queryTwinsWithResponseAsync(
} else {
querySpecification.validate();
}
return service.queryTwins(this.client.getHost(), this.client.getApiVersion(), querySpecification, context);
if (queryTwinsOptions != null) {
queryTwinsOptions.validate();
}
String traceparentInternal = null;
if (queryTwinsOptions != null) {
traceparentInternal = queryTwinsOptions.getTraceparent();
}
String traceparent = traceparentInternal;
String tracestateInternal = null;
if (queryTwinsOptions != null) {
tracestateInternal = queryTwinsOptions.getTracestate();
}
String tracestate = tracestateInternal;
Integer maxItemsPerPageInternal = null;
if (queryTwinsOptions != null) {
maxItemsPerPageInternal = queryTwinsOptions.getMaxItemsPerPage();
}
Integer maxItemsPerPage = maxItemsPerPageInternal;
return service.queryTwins(
this.client.getHost(),
traceparent,
tracestate,
maxItemsPerPage,
this.client.getApiVersion(),
querySpecification,
context);
}
}
Loading

0 comments on commit e0da820

Please sign in to comment.