From d01e6a655ffcbe3fd2522709d3b236f4174bacce Mon Sep 17 00:00:00 2001 From: Austin Lynch Date: Tue, 9 May 2023 15:25:36 -0700 Subject: [PATCH 1/6] added generated files --- .../src/generated/azureDigitalTwinsAPI.ts | 10 +- .../src/generated/models/index.ts | 151 +++++++-- .../src/generated/models/mappers.ts | 113 +++++++ .../src/generated/models/parameters.ts | 15 +- .../generated/operations/digitalTwinModels.ts | 7 +- .../src/generated/operations/digitalTwins.ts | 3 - .../src/generated/operations/eventRoutes.ts | 12 +- .../src/generated/operations/importJobs.ts | 300 ++++++++++++++++++ .../src/generated/operations/index.ts | 1 + .../operationsInterfaces/digitalTwinModels.ts | 2 + .../operationsInterfaces/eventRoutes.ts | 7 +- .../operationsInterfaces/importJobs.ts | 86 +++++ .../generated/operationsInterfaces/index.ts | 1 + 13 files changed, 669 insertions(+), 39 deletions(-) create mode 100644 sdk/digitaltwins/digital-twins-core/src/generated/operations/importJobs.ts create mode 100644 sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/importJobs.ts diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/azureDigitalTwinsAPI.ts b/sdk/digitaltwins/digital-twins-core/src/generated/azureDigitalTwinsAPI.ts index 298bda92ba41..259b5070d9df 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/azureDigitalTwinsAPI.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/azureDigitalTwinsAPI.ts @@ -16,13 +16,15 @@ import { DigitalTwinModelsImpl, QueryImpl, DigitalTwinsImpl, - EventRoutesImpl + EventRoutesImpl, + ImportJobsImpl } from "./operations"; import { DigitalTwinModels, Query, DigitalTwins, - EventRoutes + EventRoutes, + ImportJobs } from "./operationsInterfaces"; import { AzureDigitalTwinsAPIOptionalParams } from "./models"; @@ -62,11 +64,12 @@ export class AzureDigitalTwinsAPI extends coreClient.ServiceClient { // Assigning values to Constant parameters this.$host = options.$host || "https://digitaltwins-hostname"; - this.apiVersion = options.apiVersion || "2020-10-31"; + this.apiVersion = options.apiVersion || "2023-06-30"; this.digitalTwinModels = new DigitalTwinModelsImpl(this); this.query = new QueryImpl(this); this.digitalTwins = new DigitalTwinsImpl(this); this.eventRoutes = new EventRoutesImpl(this); + this.importJobs = new ImportJobsImpl(this); this.addCustomApiVersionPolicy(options.apiVersion); } @@ -102,4 +105,5 @@ export class AzureDigitalTwinsAPI extends coreClient.ServiceClient { query: Query; digitalTwins: DigitalTwins; eventRoutes: EventRoutes; + importJobs: ImportJobs; } diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/models/index.ts b/sdk/digitaltwins/digital-twins-core/src/generated/models/index.ts index 37f57e4e55e8..91db110f0f49 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/models/index.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/models/index.ts @@ -27,7 +27,7 @@ export interface DigitalTwinsModelData { /** Error response. */ export interface ErrorResponse { /** The error details. */ - error?: ErrorModel; + error: ErrorModel; } /** Error definition. */ @@ -62,7 +62,7 @@ export interface InnerError { /** A collection of DigitalTwinsModelData objects. */ export interface PagedDigitalTwinsModelDataCollection { /** The DigitalTwinsModelData objects. */ - value?: DigitalTwinsModelData[]; + value: DigitalTwinsModelData[]; /** A URI to retrieve the next page of objects. */ nextLink?: string; } @@ -78,7 +78,7 @@ export interface QuerySpecification { /** The results of a query operation and an optional continuation token. */ export interface QueryResult { /** The query results. */ - value?: Record[]; + value: Record[]; /** A token which can be used to construct a new QuerySpecification to retrieve the next set of results. */ continuationToken?: string; } @@ -86,14 +86,14 @@ export interface QueryResult { /** A collection of relationships which relate digital twins together. */ export interface RelationshipCollection { /** The relationship objects. */ - value?: Record[]; + value: Record[]; /** A URI to retrieve the next page of objects. */ nextLink?: string; } /** A collection of incoming relationships which relate digital twins together. */ export interface IncomingRelationshipCollection { - value?: IncomingRelationship[]; + value: IncomingRelationship[]; /** A URI to retrieve the next page of objects. */ nextLink?: string; } @@ -113,7 +113,7 @@ export interface IncomingRelationship { /** A collection of EventRoute objects. */ export interface EventRouteCollection { /** The EventRoute objects. */ - value?: EventRoute[]; + value: EventRoute[]; /** A URI to retrieve the next page of results. */ nextLink?: string; } @@ -131,6 +131,54 @@ export interface EventRoute { filter: string; } +/** A collection of import job objects. */ +export interface ImportJobCollection { + /** The list of import job objects. */ + value: ImportJob[]; + /** A URI to retrieve the next page of results. */ + nextLink?: string; +} + +/** A job which contains a reference to the operations to perform, results, and execution metadata. */ +export interface ImportJob { + /** + * The identifier of the import job. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly id?: string; + /** The path to the input Azure storage blob that contains file(s) describing the operations to perform in the job. */ + inputBlobUri: string; + /** The path to the output Azure storage blob that will contain the errors and progress logs of import job. */ + outputBlobUri: string; + /** + * Status of the job. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly status?: Status; + /** + * Start time of the job. The timestamp is in RFC3339 format: `yyyy-MM-ddTHH:mm:ssZ`. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly createdDateTime?: Date; + /** + * Last time service performed any action from the job. The timestamp is in RFC3339 format: `yyyy-MM-ddTHH:mm:ssZ`. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly lastActionDateTime?: Date; + /** + * End time of the job. The timestamp is in RFC3339 format: `yyyy-MM-ddTHH:mm:ssZ`. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly finishedDateTime?: Date; + /** + * Time at which job will be purged by the service from the system. The timestamp is in RFC3339 format: `yyyy-MM-ddTHH:mm:ssZ`. + * NOTE: This property will not be serialized. It can only be populated by the server. + */ + readonly purgeDateTime?: Date; + /** Details of the error(s) that occurred executing the import job. */ + error?: ErrorModel; +} + /** Defines headers for Query_queryTwins operation. */ export interface QueryQueryTwinsHeaders { /** The query charge. */ @@ -185,12 +233,18 @@ export interface DigitalTwinsUpdateComponentHeaders { etag?: string; } +/** Defines values for Status. */ +export type Status = + | "notstarted" + | "running" + | "failed" + | "succeeded" + | "cancelling" + | "cancelled"; + /** Optional parameters. */ export interface DigitalTwinModelsAddOptionalParams - extends coreClient.OperationOptions { - /** An array of models to add. */ - models?: Record[]; -} + extends coreClient.OperationOptions {} /** Contains response data for the add operation. */ export type DigitalTwinModelsAddResponse = DigitalTwinsModelData[]; @@ -198,7 +252,7 @@ export type DigitalTwinModelsAddResponse = DigitalTwinsModelData[]; /** Optional parameters. */ export interface DigitalTwinModelsListOptionalParams extends coreClient.OperationOptions { - /** The set of the models which will have their dependencies retrieved. If omitted, all models are retrieved. */ + /** If specified, only return the set of the specified models along with their dependencies. If omitted, all models are retrieved. */ dependenciesFor?: string[]; /** When true the model definition will be returned as part of the result. */ includeModelDefinition?: boolean; @@ -252,8 +306,9 @@ export interface DigitalTwinsGetByIdOptionalParams extends coreClient.OperationOptions {} /** Contains response data for the getById operation. */ -export type DigitalTwinsGetByIdResponse = DigitalTwinsGetByIdHeaders & - Record; +export type DigitalTwinsGetByIdResponse = DigitalTwinsGetByIdHeaders & { + [propertyName: string]: any; +}; /** Optional parameters. */ export interface DigitalTwinsAddOptionalParams @@ -263,8 +318,9 @@ export interface DigitalTwinsAddOptionalParams } /** Contains response data for the add operation. */ -export type DigitalTwinsAddResponse = DigitalTwinsAddHeaders & - Record; +export type DigitalTwinsAddResponse = DigitalTwinsAddHeaders & { + [propertyName: string]: any; +}; /** Optional parameters. */ export interface DigitalTwinsDeleteOptionalParams @@ -288,8 +344,9 @@ export interface DigitalTwinsGetRelationshipByIdOptionalParams extends coreClient.OperationOptions {} /** Contains response data for the getRelationshipById operation. */ -export type DigitalTwinsGetRelationshipByIdResponse = DigitalTwinsGetRelationshipByIdHeaders & - Record; +export type DigitalTwinsGetRelationshipByIdResponse = DigitalTwinsGetRelationshipByIdHeaders & { + [propertyName: string]: any; +}; /** Optional parameters. */ export interface DigitalTwinsAddRelationshipOptionalParams @@ -299,8 +356,9 @@ export interface DigitalTwinsAddRelationshipOptionalParams } /** Contains response data for the addRelationship operation. */ -export type DigitalTwinsAddRelationshipResponse = DigitalTwinsAddRelationshipHeaders & - Record; +export type DigitalTwinsAddRelationshipResponse = DigitalTwinsAddRelationshipHeaders & { + [propertyName: string]: any; +}; /** Optional parameters. */ export interface DigitalTwinsDeleteRelationshipOptionalParams @@ -355,8 +413,9 @@ export interface DigitalTwinsGetComponentOptionalParams extends coreClient.OperationOptions {} /** Contains response data for the getComponent operation. */ -export type DigitalTwinsGetComponentResponse = DigitalTwinsGetComponentHeaders & - Record; +export type DigitalTwinsGetComponentResponse = DigitalTwinsGetComponentHeaders & { + [propertyName: string]: any; +}; /** Optional parameters. */ export interface DigitalTwinsUpdateComponentOptionalParams @@ -401,10 +460,7 @@ export type EventRoutesGetByIdResponse = EventRoute; /** Optional parameters. */ export interface EventRoutesAddOptionalParams - extends coreClient.OperationOptions { - /** The event route data */ - eventRoute?: EventRoute; -} + extends coreClient.OperationOptions {} /** Optional parameters. */ export interface EventRoutesDeleteOptionalParams @@ -420,6 +476,51 @@ export interface EventRoutesListNextOptionalParams /** Contains response data for the listNext operation. */ export type EventRoutesListNextResponse = EventRouteCollection; +/** Optional parameters. */ +export interface ImportJobsListOptionalParams + extends coreClient.OperationOptions { + /** The maximum number of items to retrieve per request. The server may choose to return less than the requested number. */ + resultsPerPage?: number; +} + +/** Contains response data for the list operation. */ +export type ImportJobsListResponse = ImportJobCollection; + +/** Optional parameters. */ +export interface ImportJobsAddOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the add operation. */ +export type ImportJobsAddResponse = ImportJob; + +/** Optional parameters. */ +export interface ImportJobsGetByIdOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the getById operation. */ +export type ImportJobsGetByIdResponse = ImportJob; + +/** Optional parameters. */ +export interface ImportJobsDeleteOptionalParams + extends coreClient.OperationOptions {} + +/** Optional parameters. */ +export interface ImportJobsCancelOptionalParams + extends coreClient.OperationOptions {} + +/** Contains response data for the cancel operation. */ +export type ImportJobsCancelResponse = ImportJob; + +/** Optional parameters. */ +export interface ImportJobsListNextOptionalParams + extends coreClient.OperationOptions { + /** The maximum number of items to retrieve per request. The server may choose to return less than the requested number. */ + resultsPerPage?: number; +} + +/** Contains response data for the listNext operation. */ +export type ImportJobsListNextResponse = ImportJobCollection; + /** Optional parameters. */ export interface AzureDigitalTwinsAPIOptionalParams extends coreClient.ServiceClientOptions { diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/models/mappers.ts b/sdk/digitaltwins/digital-twins-core/src/generated/models/mappers.ts index 055c1030c345..2a0415276900 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/models/mappers.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/models/mappers.ts @@ -146,6 +146,7 @@ export const PagedDigitalTwinsModelDataCollection: coreClient.CompositeMapper = modelProperties: { value: { serializedName: "value", + required: true, type: { name: "Sequence", element: { @@ -194,6 +195,7 @@ export const QueryResult: coreClient.CompositeMapper = { modelProperties: { value: { serializedName: "value", + required: true, type: { name: "Sequence", element: { @@ -221,6 +223,7 @@ export const RelationshipCollection: coreClient.CompositeMapper = { modelProperties: { value: { serializedName: "value", + required: true, type: { name: "Sequence", element: { @@ -248,6 +251,7 @@ export const IncomingRelationshipCollection: coreClient.CompositeMapper = { modelProperties: { value: { serializedName: "value", + required: true, type: { name: "Sequence", element: { @@ -308,6 +312,7 @@ export const EventRouteCollection: coreClient.CompositeMapper = { modelProperties: { value: { serializedName: "value", + required: true, type: { name: "Sequence", element: { @@ -358,6 +363,114 @@ export const EventRoute: coreClient.CompositeMapper = { } }; +export const ImportJobCollection: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ImportJobCollection", + modelProperties: { + value: { + serializedName: "value", + required: true, + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ImportJob" + } + } + } + }, + nextLink: { + serializedName: "nextLink", + type: { + name: "String" + } + } + } + } +}; + +export const ImportJob: coreClient.CompositeMapper = { + type: { + name: "Composite", + className: "ImportJob", + modelProperties: { + id: { + serializedName: "id", + readOnly: true, + type: { + name: "String" + } + }, + inputBlobUri: { + serializedName: "inputBlobUri", + required: true, + type: { + name: "String" + } + }, + outputBlobUri: { + serializedName: "outputBlobUri", + required: true, + type: { + name: "String" + } + }, + status: { + serializedName: "status", + readOnly: true, + type: { + name: "Enum", + allowedValues: [ + "notstarted", + "running", + "failed", + "succeeded", + "cancelling", + "cancelled" + ] + } + }, + createdDateTime: { + serializedName: "createdDateTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + lastActionDateTime: { + serializedName: "lastActionDateTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + finishedDateTime: { + serializedName: "finishedDateTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + purgeDateTime: { + serializedName: "purgeDateTime", + readOnly: true, + type: { + name: "DateTime" + } + }, + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorModel" + } + } + } + } +}; + export const QueryQueryTwinsHeaders: coreClient.CompositeMapper = { type: { name: "Composite", diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/models/parameters.ts b/sdk/digitaltwins/digital-twins-core/src/generated/models/parameters.ts index 67e054eb7c58..e8e58e4a4b55 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/models/parameters.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/models/parameters.ts @@ -13,7 +13,8 @@ import { } from "@azure/core-client"; import { QuerySpecification as QuerySpecificationMapper, - EventRoute as EventRouteMapper + EventRoute as EventRouteMapper, + ImportJob as ImportJobMapper } from "../models/mappers"; export const contentType: OperationParameter = { @@ -29,13 +30,14 @@ export const contentType: OperationParameter = { }; export const models: OperationParameter = { - parameterPath: ["options", "models"], + parameterPath: "models", mapper: { constraints: { MinItems: 1, UniqueItems: true }, serializedName: "models", + required: true, type: { name: "Sequence", element: { @@ -75,7 +77,7 @@ export const $host: OperationURLParameter = { export const apiVersion: OperationQueryParameter = { parameterPath: "apiVersion", mapper: { - defaultValue: "2020-10-31", + defaultValue: "2023-06-30", isConstant: true, serializedName: "api-version", type: { @@ -305,6 +307,11 @@ export const componentPath: OperationURLParameter = { }; export const eventRoute: OperationParameter = { - parameterPath: ["options", "eventRoute"], + parameterPath: "eventRoute", mapper: EventRouteMapper }; + +export const importJob: OperationParameter = { + parameterPath: "importJob", + mapper: ImportJobMapper +}; diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwinModels.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwinModels.ts index 5a020157a2ea..35dcc55fb057 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwinModels.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwinModels.ts @@ -112,12 +112,17 @@ export class DigitalTwinModelsImpl implements DigitalTwinModels { * * ModelVersionNotSupported - The version of DTDL used is not supported. * * 409 Conflict * * ModelAlreadyExists - The model provided already exists. + * @param models An array of models to add. * @param options The options parameters. */ add( + models: Record[], options?: DigitalTwinModelsAddOptionalParams ): Promise { - return this.client.sendOperationRequest({ options }, addOperationSpec); + return this.client.sendOperationRequest( + { models, options }, + addOperationSpec + ); } /** diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwins.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwins.ts index 5bfb960332e9..510722dd52bb 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwins.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operations/digitalTwins.ts @@ -634,7 +634,6 @@ const addOperationSpec: coreClient.OperationSpec = { }, headersMapper: Mappers.DigitalTwinsAddHeaders }, - 202: {}, default: { bodyMapper: Mappers.ErrorResponse } @@ -668,7 +667,6 @@ const updateOperationSpec: coreClient.OperationSpec = { path: "/digitaltwins/{id}", httpMethod: "PATCH", responses: { - 202: {}, 204: { headersMapper: Mappers.DigitalTwinsUpdateHeaders }, @@ -864,7 +862,6 @@ const updateComponentOperationSpec: coreClient.OperationSpec = { path: "/digitaltwins/{id}/components/{componentPath}", httpMethod: "PATCH", responses: { - 202: {}, 204: { headersMapper: Mappers.DigitalTwinsUpdateComponentHeaders }, diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operations/eventRoutes.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operations/eventRoutes.ts index 12be45bf2f8f..e5ebb1464627 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/operations/eventRoutes.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operations/eventRoutes.ts @@ -135,10 +135,18 @@ export class EventRoutesImpl implements EventRoutes { * * 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 The event route data * @param options The options parameters. */ - add(id: string, options?: EventRoutesAddOptionalParams): Promise { - return this.client.sendOperationRequest({ id, options }, addOperationSpec); + add( + id: string, + eventRoute: EventRoute, + options?: EventRoutesAddOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { id, eventRoute, options }, + addOperationSpec + ); } /** diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operations/importJobs.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operations/importJobs.ts new file mode 100644 index 000000000000..d23ed5c4e8ff --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operations/importJobs.ts @@ -0,0 +1,300 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging"; +import { setContinuationToken } from "../pagingHelper"; +import { ImportJobs } from "../operationsInterfaces"; +import * as coreClient from "@azure/core-client"; +import * as Mappers from "../models/mappers"; +import * as Parameters from "../models/parameters"; +import { AzureDigitalTwinsAPI } from "../azureDigitalTwinsAPI"; +import { + ImportJob, + ImportJobsListNextOptionalParams, + ImportJobsListOptionalParams, + ImportJobsListResponse, + ImportJobsAddOptionalParams, + ImportJobsAddResponse, + ImportJobsGetByIdOptionalParams, + ImportJobsGetByIdResponse, + ImportJobsDeleteOptionalParams, + ImportJobsCancelOptionalParams, + ImportJobsCancelResponse, + ImportJobsListNextResponse +} from "../models"; + +/// +/** Class containing ImportJobs operations. */ +export class ImportJobsImpl implements ImportJobs { + private readonly client: AzureDigitalTwinsAPI; + + /** + * Initialize a new instance of the class ImportJobs class. + * @param client Reference to the service client + */ + constructor(client: AzureDigitalTwinsAPI) { + this.client = client; + } + + /** + * Retrieves all import jobs. + * Status codes: + * * 200 OK + * @param options The options parameters. + */ + public list( + options?: ImportJobsListOptionalParams + ): PagedAsyncIterableIterator { + const iter = this.listPagingAll(options); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: (settings?: PageSettings) => { + if (settings?.maxPageSize) { + throw new Error("maxPageSize is not supported by this operation."); + } + return this.listPagingPage(options, settings); + } + }; + } + + private async *listPagingPage( + options?: ImportJobsListOptionalParams, + settings?: PageSettings + ): AsyncIterableIterator { + let result: ImportJobsListResponse; + let continuationToken = settings?.continuationToken; + if (!continuationToken) { + result = await this._list(options); + let page = result.value || []; + continuationToken = result.nextLink; + setContinuationToken(page, continuationToken); + yield page; + } + while (continuationToken) { + result = await this._listNext(continuationToken, options); + continuationToken = result.nextLink; + let page = result.value || []; + setContinuationToken(page, continuationToken); + yield page; + } + } + + private async *listPagingAll( + options?: ImportJobsListOptionalParams + ): AsyncIterableIterator { + for await (const page of this.listPagingPage(options)) { + yield* page; + } + } + + /** + * Retrieves all import jobs. + * Status codes: + * * 200 OK + * @param options The options parameters. + */ + private _list( + options?: ImportJobsListOptionalParams + ): Promise { + return this.client.sendOperationRequest({ options }, listOperationSpec); + } + + /** + * Creates an import job. + * Status codes: + * * 201 Created + * * 400 Bad Request + * * JobLimitReached - The maximum number of import jobs allowed has been reached. + * * ValidationFailed - The import job request is not valid. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param importJob The import job being added. + * @param options The options parameters. + */ + add( + id: string, + importJob: ImportJob, + options?: ImportJobsAddOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { id, importJob, options }, + addOperationSpec + ); + } + + /** + * Retrieves an import job. + * Status codes: + * * 200 OK + * * 404 Not Found + * * ImportJobNotFound - The import job was not found. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param options The options parameters. + */ + getById( + id: string, + options?: ImportJobsGetByIdOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { id, options }, + getByIdOperationSpec + ); + } + + /** + * Deletes an import job. + * Status codes: + * * 204 No Content + * * 400 Bad Request + * * ValidationFailed - The import job request is not valid. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param options The options parameters. + */ + delete(id: string, options?: ImportJobsDeleteOptionalParams): Promise { + return this.client.sendOperationRequest( + { id, options }, + deleteOperationSpec + ); + } + + /** + * Cancels an import job. + * Status codes: + * * 200 Request Accepted + * * 400 Bad Request + * * ValidationFailed - The import job request is not valid. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param options The options parameters. + */ + cancel( + id: string, + options?: ImportJobsCancelOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { id, options }, + cancelOperationSpec + ); + } + + /** + * ListNext + * @param nextLink The nextLink from the previous successful call to the List method. + * @param options The options parameters. + */ + private _listNext( + nextLink: string, + options?: ImportJobsListNextOptionalParams + ): Promise { + return this.client.sendOperationRequest( + { nextLink, options }, + listNextOperationSpec + ); + } +} +// Operation Specifications +const serializer = coreClient.createSerializer(Mappers, /* isXml */ false); + +const listOperationSpec: coreClient.OperationSpec = { + path: "/jobs/imports", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ImportJobCollection + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host], + headerParameters: [Parameters.accept, Parameters.resultsPerPage], + serializer +}; +const addOperationSpec: coreClient.OperationSpec = { + path: "/jobs/imports/{id}", + httpMethod: "PUT", + responses: { + 201: { + bodyMapper: Mappers.ImportJob + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + requestBody: Parameters.importJob, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.id], + headerParameters: [Parameters.contentType, Parameters.accept], + mediaType: "json", + serializer +}; +const getByIdOperationSpec: coreClient.OperationSpec = { + path: "/jobs/imports/{id}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ImportJob + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.id], + headerParameters: [Parameters.accept], + serializer +}; +const deleteOperationSpec: coreClient.OperationSpec = { + path: "/jobs/imports/{id}", + httpMethod: "DELETE", + responses: { + 204: {}, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.id], + headerParameters: [Parameters.accept], + serializer +}; +const cancelOperationSpec: coreClient.OperationSpec = { + path: "/jobs/imports/{id}/cancel", + httpMethod: "POST", + responses: { + 200: { + bodyMapper: Mappers.ImportJob + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + queryParameters: [Parameters.apiVersion], + urlParameters: [Parameters.$host, Parameters.id], + headerParameters: [Parameters.accept], + serializer +}; +const listNextOperationSpec: coreClient.OperationSpec = { + path: "{nextLink}", + httpMethod: "GET", + responses: { + 200: { + bodyMapper: Mappers.ImportJobCollection + }, + default: { + bodyMapper: Mappers.ErrorResponse + } + }, + urlParameters: [Parameters.$host, Parameters.nextLink], + headerParameters: [Parameters.accept, Parameters.resultsPerPage], + serializer +}; diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operations/index.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operations/index.ts index 09b1d29c4654..f33834f1f466 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/operations/index.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operations/index.ts @@ -10,3 +10,4 @@ export * from "./digitalTwinModels"; export * from "./query"; export * from "./digitalTwins"; export * from "./eventRoutes"; +export * from "./importJobs"; diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/digitalTwinModels.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/digitalTwinModels.ts index 0f88e00da438..a9314fc31339 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/digitalTwinModels.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/digitalTwinModels.ts @@ -46,9 +46,11 @@ export interface DigitalTwinModels { * * ModelVersionNotSupported - The version of DTDL used is not supported. * * 409 Conflict * * ModelAlreadyExists - The model provided already exists. + * @param models An array of models to add. * @param options The options parameters. */ add( + models: Record[], options?: DigitalTwinModelsAddOptionalParams ): Promise; /** diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/eventRoutes.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/eventRoutes.ts index 2fc9b43304a9..2ea351f87fa9 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/eventRoutes.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/eventRoutes.ts @@ -51,9 +51,14 @@ export interface EventRoutes { * * 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 The event route data * @param options The options parameters. */ - add(id: string, options?: EventRoutesAddOptionalParams): Promise; + add( + id: string, + eventRoute: EventRoute, + options?: EventRoutesAddOptionalParams + ): Promise; /** * Deletes an event route. * Status codes: diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/importJobs.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/importJobs.ts new file mode 100644 index 000000000000..e5d3d9b79065 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/importJobs.ts @@ -0,0 +1,86 @@ +/* + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is regenerated. + */ + +import { PagedAsyncIterableIterator } from "@azure/core-paging"; +import { + ImportJob, + ImportJobsListOptionalParams, + ImportJobsAddOptionalParams, + ImportJobsAddResponse, + ImportJobsGetByIdOptionalParams, + ImportJobsGetByIdResponse, + ImportJobsDeleteOptionalParams, + ImportJobsCancelOptionalParams, + ImportJobsCancelResponse +} from "../models"; + +/// +/** Interface representing a ImportJobs. */ +export interface ImportJobs { + /** + * Retrieves all import jobs. + * Status codes: + * * 200 OK + * @param options The options parameters. + */ + list( + options?: ImportJobsListOptionalParams + ): PagedAsyncIterableIterator; + /** + * Creates an import job. + * Status codes: + * * 201 Created + * * 400 Bad Request + * * JobLimitReached - The maximum number of import jobs allowed has been reached. + * * ValidationFailed - The import job request is not valid. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param importJob The import job being added. + * @param options The options parameters. + */ + add( + id: string, + importJob: ImportJob, + options?: ImportJobsAddOptionalParams + ): Promise; + /** + * Retrieves an import job. + * Status codes: + * * 200 OK + * * 404 Not Found + * * ImportJobNotFound - The import job was not found. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param options The options parameters. + */ + getById( + id: string, + options?: ImportJobsGetByIdOptionalParams + ): Promise; + /** + * Deletes an import job. + * Status codes: + * * 204 No Content + * * 400 Bad Request + * * ValidationFailed - The import job request is not valid. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param options The options parameters. + */ + delete(id: string, options?: ImportJobsDeleteOptionalParams): Promise; + /** + * Cancels an import job. + * Status codes: + * * 200 Request Accepted + * * 400 Bad Request + * * ValidationFailed - The import job request is not valid. + * @param id The id for the import job. The id is unique within the service and case sensitive. + * @param options The options parameters. + */ + cancel( + id: string, + options?: ImportJobsCancelOptionalParams + ): Promise; +} diff --git a/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/index.ts b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/index.ts index 09b1d29c4654..f33834f1f466 100644 --- a/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/index.ts +++ b/sdk/digitaltwins/digital-twins-core/src/generated/operationsInterfaces/index.ts @@ -10,3 +10,4 @@ export * from "./digitalTwinModels"; export * from "./query"; export * from "./digitalTwins"; export * from "./eventRoutes"; +export * from "./importJobs"; From 6b10fe9cb59e6c219ecc6df69d83c1ae73cf2fcd Mon Sep 17 00:00:00 2001 From: Austin Lynch Date: Thu, 11 May 2023 15:47:01 -0700 Subject: [PATCH 2/6] Added samples --- .../samples-dev/dt_import_jobs_get.ts | 39 ++++++++ .../samples-dev/dt_import_jobs_lifecycle.ts | 76 ++++++++++++++ .../samples-dev/dt_import_jobs_list.ts | 40 ++++++++ .../v1/javascript/dt_import_jobs_get.js | 39 ++++++++ .../v1/javascript/dt_import_jobs_lifecycle.js | 76 ++++++++++++++ .../v1/javascript/dt_import_jobs_list.js | 40 ++++++++ .../v1/typescript/src/dt_import_jobs_get.ts | 39 ++++++++ .../src/dt_import_jobs_lifecycle.ts | 76 ++++++++++++++ .../v1/typescript/src/dt_import_jobs_list.ts | 40 ++++++++ .../v2/javascript/dt_import_jobs_get.js | 39 ++++++++ .../v2/javascript/dt_import_jobs_lifecycle.js | 76 ++++++++++++++ .../v2/javascript/dt_import_jobs_list.js | 40 ++++++++ .../v2/typescript/src/dt_import_jobs_get.ts | 39 ++++++++ .../src/dt_import_jobs_lifecycle.ts | 76 ++++++++++++++ .../v2/typescript/src/dt_import_jobs_list.ts | 40 ++++++++ .../src/digitalTwinsClient.ts | 98 +++++++++++++++++++ 16 files changed, 873 insertions(+) create mode 100644 sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_get.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_list.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_get.js create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_list.js create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_get.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_list.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_get.js create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_list.js create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_get.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts create mode 100644 sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_list.ts diff --git a/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_get.ts b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_get.ts new file mode 100644 index 000000000000..b0053d6dda4d --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_get.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to get an import job. + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Get event route + const importJobId = ""; // Import Job ID must exist in your Azure Digital Twins instance + const importJob = serviceClient.getImportJob(importJobId); + console.log(`EventRoute:`); + console.log(inspect(importJob)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts new file mode 100644 index 000000000000..cdc9e43c9692 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * This sample illustrates the lifecycle of an import job using a scenario that shows how to: + * - create a DigitalTwins Service Client using the DigitalTwinsClient constructor + * - create an import job + * - get created import job by importJobId + * - list all import jobs by listing them using the paginated API + * - cancel the created import job + * - delete the created import job + * + * @summary demonstrates the lifecycle (create, get, list, decommission, delete) of a model + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; +import { v4 } from "uuid"; + +// For the purpose of this example we will create temporary model and a temporary component model using random Ids. +// We have to make sure these model Ids are unique within the DT instance so we use generated UUIDs. +async function main() { + const importJobId = `import-job-${v4()}`; + const inputBlobUri = ""; // Input blob file in a storage container with the correct permissions required; + const outputBlobUri = ""; //Storage container with correct permissions required. If output blob file does not exist, one will be created; + + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Create import job + const createdImportJob = await serviceClient.upsertImportJob(importJobId, inputBlobUri, outputBlobUri); + console.log(`Created import Job:`); + console.log(inspect(createdImportJob)); + + // Get created import job + const getImportJob = await serviceClient.getImportJob(importJobId); + console.log(`Get Import Job:`); + console.log(inspect(getImportJob)); + + // List all import jobs + const listedImportJobs = serviceClient.listImportJobs(); + console.log(`Import Job list`); + for await (const importJob of listedImportJobs) { + console.log(`Import Job:`); + console.log(inspect(importJob)); + } + + // Decommission import jobs + let response = await serviceClient.cancelImportJob(importJobId); + console.log(`Cancel Import Job response:`); + console.log(inspect(response)); + + // Delete import jobs + response = await serviceClient.deleteImportJob(importJobId); + console.log(`Delete Model response:`); + console.log(inspect(response)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_list.ts b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_list.ts new file mode 100644 index 000000000000..d32db1789177 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_list.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to list all import jobs using the paginated API + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // List event routes + const importJobs = serviceClient.listImportJobs(); + for await (const importJob of importJobs) { + console.log(`ImportJob:`); + console.log(inspect(importJob)); + } +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_get.js b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_get.js new file mode 100644 index 000000000000..b0053d6dda4d --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_get.js @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to get an import job. + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Get event route + const importJobId = ""; // Import Job ID must exist in your Azure Digital Twins instance + const importJob = serviceClient.getImportJob(importJobId); + console.log(`EventRoute:`); + console.log(inspect(importJob)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js new file mode 100644 index 000000000000..cdc9e43c9692 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * This sample illustrates the lifecycle of an import job using a scenario that shows how to: + * - create a DigitalTwins Service Client using the DigitalTwinsClient constructor + * - create an import job + * - get created import job by importJobId + * - list all import jobs by listing them using the paginated API + * - cancel the created import job + * - delete the created import job + * + * @summary demonstrates the lifecycle (create, get, list, decommission, delete) of a model + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; +import { v4 } from "uuid"; + +// For the purpose of this example we will create temporary model and a temporary component model using random Ids. +// We have to make sure these model Ids are unique within the DT instance so we use generated UUIDs. +async function main() { + const importJobId = `import-job-${v4()}`; + const inputBlobUri = ""; // Input blob file in a storage container with the correct permissions required; + const outputBlobUri = ""; //Storage container with correct permissions required. If output blob file does not exist, one will be created; + + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Create import job + const createdImportJob = await serviceClient.upsertImportJob(importJobId, inputBlobUri, outputBlobUri); + console.log(`Created import Job:`); + console.log(inspect(createdImportJob)); + + // Get created import job + const getImportJob = await serviceClient.getImportJob(importJobId); + console.log(`Get Import Job:`); + console.log(inspect(getImportJob)); + + // List all import jobs + const listedImportJobs = serviceClient.listImportJobs(); + console.log(`Import Job list`); + for await (const importJob of listedImportJobs) { + console.log(`Import Job:`); + console.log(inspect(importJob)); + } + + // Decommission import jobs + let response = await serviceClient.cancelImportJob(importJobId); + console.log(`Cancel Import Job response:`); + console.log(inspect(response)); + + // Delete import jobs + response = await serviceClient.deleteImportJob(importJobId); + console.log(`Delete Model response:`); + console.log(inspect(response)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_list.js b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_list.js new file mode 100644 index 000000000000..d32db1789177 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_list.js @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to list all import jobs using the paginated API + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // List event routes + const importJobs = serviceClient.listImportJobs(); + for await (const importJob of importJobs) { + console.log(`ImportJob:`); + console.log(inspect(importJob)); + } +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_get.ts b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_get.ts new file mode 100644 index 000000000000..b0053d6dda4d --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_get.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to get an import job. + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Get event route + const importJobId = ""; // Import Job ID must exist in your Azure Digital Twins instance + const importJob = serviceClient.getImportJob(importJobId); + console.log(`EventRoute:`); + console.log(inspect(importJob)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts new file mode 100644 index 000000000000..cdc9e43c9692 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * This sample illustrates the lifecycle of an import job using a scenario that shows how to: + * - create a DigitalTwins Service Client using the DigitalTwinsClient constructor + * - create an import job + * - get created import job by importJobId + * - list all import jobs by listing them using the paginated API + * - cancel the created import job + * - delete the created import job + * + * @summary demonstrates the lifecycle (create, get, list, decommission, delete) of a model + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; +import { v4 } from "uuid"; + +// For the purpose of this example we will create temporary model and a temporary component model using random Ids. +// We have to make sure these model Ids are unique within the DT instance so we use generated UUIDs. +async function main() { + const importJobId = `import-job-${v4()}`; + const inputBlobUri = ""; // Input blob file in a storage container with the correct permissions required; + const outputBlobUri = ""; //Storage container with correct permissions required. If output blob file does not exist, one will be created; + + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Create import job + const createdImportJob = await serviceClient.upsertImportJob(importJobId, inputBlobUri, outputBlobUri); + console.log(`Created import Job:`); + console.log(inspect(createdImportJob)); + + // Get created import job + const getImportJob = await serviceClient.getImportJob(importJobId); + console.log(`Get Import Job:`); + console.log(inspect(getImportJob)); + + // List all import jobs + const listedImportJobs = serviceClient.listImportJobs(); + console.log(`Import Job list`); + for await (const importJob of listedImportJobs) { + console.log(`Import Job:`); + console.log(inspect(importJob)); + } + + // Decommission import jobs + let response = await serviceClient.cancelImportJob(importJobId); + console.log(`Cancel Import Job response:`); + console.log(inspect(response)); + + // Delete import jobs + response = await serviceClient.deleteImportJob(importJobId); + console.log(`Delete Model response:`); + console.log(inspect(response)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_list.ts b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_list.ts new file mode 100644 index 000000000000..d32db1789177 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_list.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to list all import jobs using the paginated API + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // List event routes + const importJobs = serviceClient.listImportJobs(); + for await (const importJob of importJobs) { + console.log(`ImportJob:`); + console.log(inspect(importJob)); + } +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_get.js b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_get.js new file mode 100644 index 000000000000..b0053d6dda4d --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_get.js @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to get an import job. + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Get event route + const importJobId = ""; // Import Job ID must exist in your Azure Digital Twins instance + const importJob = serviceClient.getImportJob(importJobId); + console.log(`EventRoute:`); + console.log(inspect(importJob)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js new file mode 100644 index 000000000000..cdc9e43c9692 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * This sample illustrates the lifecycle of an import job using a scenario that shows how to: + * - create a DigitalTwins Service Client using the DigitalTwinsClient constructor + * - create an import job + * - get created import job by importJobId + * - list all import jobs by listing them using the paginated API + * - cancel the created import job + * - delete the created import job + * + * @summary demonstrates the lifecycle (create, get, list, decommission, delete) of a model + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; +import { v4 } from "uuid"; + +// For the purpose of this example we will create temporary model and a temporary component model using random Ids. +// We have to make sure these model Ids are unique within the DT instance so we use generated UUIDs. +async function main() { + const importJobId = `import-job-${v4()}`; + const inputBlobUri = ""; // Input blob file in a storage container with the correct permissions required; + const outputBlobUri = ""; //Storage container with correct permissions required. If output blob file does not exist, one will be created; + + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Create import job + const createdImportJob = await serviceClient.upsertImportJob(importJobId, inputBlobUri, outputBlobUri); + console.log(`Created import Job:`); + console.log(inspect(createdImportJob)); + + // Get created import job + const getImportJob = await serviceClient.getImportJob(importJobId); + console.log(`Get Import Job:`); + console.log(inspect(getImportJob)); + + // List all import jobs + const listedImportJobs = serviceClient.listImportJobs(); + console.log(`Import Job list`); + for await (const importJob of listedImportJobs) { + console.log(`Import Job:`); + console.log(inspect(importJob)); + } + + // Decommission import jobs + let response = await serviceClient.cancelImportJob(importJobId); + console.log(`Cancel Import Job response:`); + console.log(inspect(response)); + + // Delete import jobs + response = await serviceClient.deleteImportJob(importJobId); + console.log(`Delete Model response:`); + console.log(inspect(response)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_list.js b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_list.js new file mode 100644 index 000000000000..d32db1789177 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_list.js @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to list all import jobs using the paginated API + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // List event routes + const importJobs = serviceClient.listImportJobs(); + for await (const importJob of importJobs) { + console.log(`ImportJob:`); + console.log(inspect(importJob)); + } +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_get.ts b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_get.ts new file mode 100644 index 000000000000..b0053d6dda4d --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_get.ts @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to get an import job. + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Get event route + const importJobId = ""; // Import Job ID must exist in your Azure Digital Twins instance + const importJob = serviceClient.getImportJob(importJobId); + console.log(`EventRoute:`); + console.log(inspect(importJob)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts new file mode 100644 index 000000000000..cdc9e43c9692 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * This sample illustrates the lifecycle of an import job using a scenario that shows how to: + * - create a DigitalTwins Service Client using the DigitalTwinsClient constructor + * - create an import job + * - get created import job by importJobId + * - list all import jobs by listing them using the paginated API + * - cancel the created import job + * - delete the created import job + * + * @summary demonstrates the lifecycle (create, get, list, decommission, delete) of a model + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; +import { v4 } from "uuid"; + +// For the purpose of this example we will create temporary model and a temporary component model using random Ids. +// We have to make sure these model Ids are unique within the DT instance so we use generated UUIDs. +async function main() { + const importJobId = `import-job-${v4()}`; + const inputBlobUri = ""; // Input blob file in a storage container with the correct permissions required; + const outputBlobUri = ""; //Storage container with correct permissions required. If output blob file does not exist, one will be created; + + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // Create import job + const createdImportJob = await serviceClient.upsertImportJob(importJobId, inputBlobUri, outputBlobUri); + console.log(`Created import Job:`); + console.log(inspect(createdImportJob)); + + // Get created import job + const getImportJob = await serviceClient.getImportJob(importJobId); + console.log(`Get Import Job:`); + console.log(inspect(getImportJob)); + + // List all import jobs + const listedImportJobs = serviceClient.listImportJobs(); + console.log(`Import Job list`); + for await (const importJob of listedImportJobs) { + console.log(`Import Job:`); + console.log(inspect(importJob)); + } + + // Decommission import jobs + let response = await serviceClient.cancelImportJob(importJobId); + console.log(`Cancel Import Job response:`); + console.log(inspect(response)); + + // Delete import jobs + response = await serviceClient.deleteImportJob(importJobId); + console.log(`Delete Model response:`); + console.log(inspect(response)); +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_list.ts b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_list.ts new file mode 100644 index 000000000000..d32db1789177 --- /dev/null +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_list.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/** + * @summary Simple example of how to list all import jobs using the paginated API + */ + +import { DefaultAzureCredential } from "@azure/identity"; +import { DigitalTwinsClient } from "@azure/digital-twins-core"; +import { inspect } from "util"; + +async function main() { + // AZURE_DIGITALTWINS_URL: The URL to your Azure Digital Twins instance + const url = process.env.AZURE_DIGITALTWINS_URL; + if (url === undefined) { + throw new Error("Required environment variable AZURE_DIGITALTWINS_URL is not set."); + } + + // DefaultAzureCredential is provided by @azure/identity. It supports + // different authentication mechanisms and determines the appropriate + // credential type based of the environment it is executing in. See + // https://www.npmjs.com/package/@azure/identity for more information on + // authenticating with DefaultAzureCredential or other implementations of + // TokenCredential. + const credential = new DefaultAzureCredential(); + const serviceClient = new DigitalTwinsClient(url, credential); + + // List event routes + const importJobs = serviceClient.listImportJobs(); + for await (const importJob of importJobs) { + console.log(`ImportJob:`); + console.log(inspect(importJob)); + } +} + +main().catch((err) => { + console.log("error code: ", err.code); + console.log("error message: ", err.message); + console.log("error stack: ", err.stack); +}); diff --git a/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts b/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts index da9be809ca8d..782f14163271 100644 --- a/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts +++ b/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts @@ -39,6 +39,9 @@ import { EventRoutesListOptionalParams as ListEventRoutesOptions, DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions, DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions, + ImportJob, + ImportJobsGetByIdResponse, + ImportJobsListOptionalParams as ListImportJobsOptions, } from "./generated/models"; import { tracingClient } from "./tracing"; import { logger } from "./logger"; @@ -49,6 +52,7 @@ export { ListEventRoutesOptions, ListIncomingRelationshipsOptions, ListRelationshipsOptions, + ListImportJobsOptions, }; /** @@ -690,4 +694,98 @@ export class DigitalTwinsClient { byPage: (settings: PageSettings = {}) => this.queryTwinsPage(query, options, settings), }; } + + /** + * Get an import job. + * + * @param importJobId - The Id of the import job. + * @param options - The operation options + * @returns The application/json import job. + */ + public getImportJob( + importJobId: string, + options: OperationOptions = {} + ): Promise { + return tracingClient.withSpan( + "DigitalTwinsClient.getImportJob", + options, + async (updatedOptions) => { + return this.client.importJobs.getById(importJobId, updatedOptions); + } + ); + } + + /** + * List the import jobs. + * + * @param options - Options for listImportJobs. + * @returns The application/json import job. + */ + public listImportJobs(options?: ListImportJobsOptions): PagedAsyncIterableIterator { + return this.client.importJobs.list(options); + } + + /** + * Create or update an import job. + * + * @param importJobId - The Id of the import job to create or update. + * @param inputBlobUri - The endpoint of the input blob file + * @param outputBlobUri - The endpoint of the output blob file + * @param options - The operation options + + */ + public upsertImportJob( + importJobId: string, + inputBlobUri: string, + outputBlobUri: string, + options: OperationOptions = {} + ): Promise { + return tracingClient.withSpan( + "DigitalTwinsClient.upsertImportJob", + { + ImportJob: { + endpointName: inputBlobUri, + outputBlobUri: outputBlobUri, + }, + ...options, + }, + async (updatedOptions) => { + return this.client.importJobs.add(importJobId, updatedOptions); + } + ); + } + + /** + * Delete an import job + * + * @param importJobId - The Id of the ImportJob to delete. + * @param options - The operation options + + */ + public deleteImportJob(importJobId: string, options: OperationOptions = {}): Promise { + return tracingClient.withSpan( + "DigitalTwinsClient.deleteImportJob", + options, + async (updatedOptions) => { + return this.client.importJobs.delete(importJobId, updatedOptions); + } + ); + } + + /** + * Cancel an import job + * + * @param importJobId - The Id of the ImportJob to cancel. + * @param options - The operation options + + */ + public cancelImportJob(importJobId: string, options: OperationOptions = {}): Promise { + return tracingClient.withSpan( + "DigitalTwinsClient.cancelImportJob", + options, + async (updatedOptions) => { + return this.client.importJobs.cancel(importJobId, updatedOptions); + } + ); + } } From 5e409ace5dcf79980caeea954b269c67f63c87fe Mon Sep 17 00:00:00 2001 From: Austin Lynch Date: Mon, 15 May 2023 22:19:19 -0700 Subject: [PATCH 3/6] updated sample comments and fixed errors --- .../samples-dev/dt_import_jobs_lifecycle.ts | 6 +++--- .../samples/v1/javascript/dt_import_jobs_lifecycle.js | 6 +++--- .../v1/typescript/src/dt_import_jobs_lifecycle.ts | 6 +++--- .../samples/v2/javascript/dt_import_jobs_lifecycle.js | 6 +++--- .../v2/typescript/src/dt_import_jobs_lifecycle.ts | 6 +++--- .../digital-twins-core/src/digitalTwinsClient.ts | 11 +++++------ 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts index cdc9e43c9692..0c4ac2756c9e 100644 --- a/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts +++ b/sdk/digitaltwins/digital-twins-core/samples-dev/dt_import_jobs_lifecycle.ts @@ -58,13 +58,13 @@ async function main() { console.log(inspect(importJob)); } - // Decommission import jobs + // Cancel import job let response = await serviceClient.cancelImportJob(importJobId); console.log(`Cancel Import Job response:`); console.log(inspect(response)); - // Delete import jobs - response = await serviceClient.deleteImportJob(importJobId); + // Delete import job + await serviceClient.deleteImportJob(importJobId); console.log(`Delete Model response:`); console.log(inspect(response)); } diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js index cdc9e43c9692..0c4ac2756c9e 100644 --- a/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/javascript/dt_import_jobs_lifecycle.js @@ -58,13 +58,13 @@ async function main() { console.log(inspect(importJob)); } - // Decommission import jobs + // Cancel import job let response = await serviceClient.cancelImportJob(importJobId); console.log(`Cancel Import Job response:`); console.log(inspect(response)); - // Delete import jobs - response = await serviceClient.deleteImportJob(importJobId); + // Delete import job + await serviceClient.deleteImportJob(importJobId); console.log(`Delete Model response:`); console.log(inspect(response)); } diff --git a/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts index cdc9e43c9692..0c4ac2756c9e 100644 --- a/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts +++ b/sdk/digitaltwins/digital-twins-core/samples/v1/typescript/src/dt_import_jobs_lifecycle.ts @@ -58,13 +58,13 @@ async function main() { console.log(inspect(importJob)); } - // Decommission import jobs + // Cancel import job let response = await serviceClient.cancelImportJob(importJobId); console.log(`Cancel Import Job response:`); console.log(inspect(response)); - // Delete import jobs - response = await serviceClient.deleteImportJob(importJobId); + // Delete import job + await serviceClient.deleteImportJob(importJobId); console.log(`Delete Model response:`); console.log(inspect(response)); } diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js index cdc9e43c9692..0c4ac2756c9e 100644 --- a/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/javascript/dt_import_jobs_lifecycle.js @@ -58,13 +58,13 @@ async function main() { console.log(inspect(importJob)); } - // Decommission import jobs + // Cancel import job let response = await serviceClient.cancelImportJob(importJobId); console.log(`Cancel Import Job response:`); console.log(inspect(response)); - // Delete import jobs - response = await serviceClient.deleteImportJob(importJobId); + // Delete import job + await serviceClient.deleteImportJob(importJobId); console.log(`Delete Model response:`); console.log(inspect(response)); } diff --git a/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts index cdc9e43c9692..0c4ac2756c9e 100644 --- a/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts +++ b/sdk/digitaltwins/digital-twins-core/samples/v2/typescript/src/dt_import_jobs_lifecycle.ts @@ -58,13 +58,13 @@ async function main() { console.log(inspect(importJob)); } - // Decommission import jobs + // Cancel import job let response = await serviceClient.cancelImportJob(importJobId); console.log(`Cancel Import Job response:`); console.log(inspect(response)); - // Delete import jobs - response = await serviceClient.deleteImportJob(importJobId); + // Delete import job + await serviceClient.deleteImportJob(importJobId); console.log(`Delete Model response:`); console.log(inspect(response)); } diff --git a/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts b/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts index 782f14163271..79450e4ac4ce 100644 --- a/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts +++ b/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts @@ -40,7 +40,6 @@ import { DigitalTwinsListRelationshipsOptionalParams as ListRelationshipsOptions, DigitalTwinsListIncomingRelationshipsOptionalParams as ListIncomingRelationshipsOptions, ImportJob, - ImportJobsGetByIdResponse, ImportJobsListOptionalParams as ListImportJobsOptions, } from "./generated/models"; import { tracingClient } from "./tracing"; @@ -705,7 +704,7 @@ export class DigitalTwinsClient { public getImportJob( importJobId: string, options: OperationOptions = {} - ): Promise { + ): Promise { return tracingClient.withSpan( "DigitalTwinsClient.getImportJob", options, @@ -739,13 +738,13 @@ export class DigitalTwinsClient { inputBlobUri: string, outputBlobUri: string, options: OperationOptions = {} - ): Promise { + ): Promise { return tracingClient.withSpan( "DigitalTwinsClient.upsertImportJob", { ImportJob: { - endpointName: inputBlobUri, - outputBlobUri: outputBlobUri, + inputBlobUri, + outputBlobUri, }, ...options, }, @@ -779,7 +778,7 @@ export class DigitalTwinsClient { * @param options - The operation options */ - public cancelImportJob(importJobId: string, options: OperationOptions = {}): Promise { + public cancelImportJob(importJobId: string, options: OperationOptions = {}): Promise { return tracingClient.withSpan( "DigitalTwinsClient.cancelImportJob", options, From f9ed1f2fdb868d1ff044910feed79bfa0f1e3eb4 Mon Sep 17 00:00:00 2001 From: Austin Lynch Date: Tue, 16 May 2023 13:11:07 -0700 Subject: [PATCH 4/6] Fixed further build errors --- .../digital-twins-core/src/digitalTwinsClient.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts b/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts index 79450e4ac4ce..e7e17f8a129f 100644 --- a/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts +++ b/sdk/digitaltwins/digital-twins-core/src/digitalTwinsClient.ts @@ -505,7 +505,7 @@ export class DigitalTwinsClient { models: dtdlModels, }, async (updatedOptions) => { - return this.client.digitalTwinModels.add(updatedOptions); + return this.client.digitalTwinModels.add(updatedOptions.models, updatedOptions); } ); } @@ -601,12 +601,12 @@ export class DigitalTwinsClient { { eventRoute: { endpointName: endpointId, - filter, + filter: filter, }, ...options, }, async (updatedOptions) => { - return this.client.eventRoutes.add(eventRouteId, updatedOptions); + return this.client.eventRoutes.add(eventRouteId, updatedOptions.eventRoute, updatedOptions); } ); } @@ -742,14 +742,14 @@ export class DigitalTwinsClient { return tracingClient.withSpan( "DigitalTwinsClient.upsertImportJob", { - ImportJob: { - inputBlobUri, - outputBlobUri, + importJob: { + inputBlobUri: inputBlobUri, + outputBlobUri: outputBlobUri, }, ...options, }, async (updatedOptions) => { - return this.client.importJobs.add(importJobId, updatedOptions); + return this.client.importJobs.add(importJobId, updatedOptions.importJob, updatedOptions); } ); } From 0cfb28ef0baa040b5267f8332e68eb5e24bb1f91 Mon Sep 17 00:00:00 2001 From: Austin Lynch Date: Tue, 30 May 2023 21:54:16 -0700 Subject: [PATCH 5/6] Updated changelog to describe new import job feature --- sdk/digitaltwins/digital-twins-core/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/digitaltwins/digital-twins-core/CHANGELOG.md b/sdk/digitaltwins/digital-twins-core/CHANGELOG.md index 0853b3e05ac1..bd2444c0a2b6 100644 --- a/sdk/digitaltwins/digital-twins-core/CHANGELOG.md +++ b/sdk/digitaltwins/digital-twins-core/CHANGELOG.md @@ -1,5 +1,10 @@ # Release History +## 2.1.0 (Beta) +### Features Added +- Updated service API version to use API version 2023-06-30 by default. +- Added support for the new import job. You can now use a blob file in your storage account to import multiple models, twins and relationships at once. + ## 2.0.0 (Unreleased) ### Features Added From 9d9c71c804a5d6dbc219b1bdba8436cda7aad04b Mon Sep 17 00:00:00 2001 From: Austin Lynch Date: Tue, 20 Jun 2023 18:32:42 -0700 Subject: [PATCH 6/6] updated changelogs and readmes --- .../digital-twins-core/CHANGELOG.md | 2 +- .../review/digital-twins-core.api.md | 37 ++++++++++++++----- .../digital-twins-core/swagger/README.md | 2 +- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/sdk/digitaltwins/digital-twins-core/CHANGELOG.md b/sdk/digitaltwins/digital-twins-core/CHANGELOG.md index bd2444c0a2b6..0c811ff43fd3 100644 --- a/sdk/digitaltwins/digital-twins-core/CHANGELOG.md +++ b/sdk/digitaltwins/digital-twins-core/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 2.1.0 (Beta) +## 2.1.0-beta.1 (2023-06-01) ### Features Added - Updated service API version to use API version 2023-06-30 by default. - Added support for the new import job. You can now use a blob file in your storage account to import multiple models, twins and relationships at once. diff --git a/sdk/digitaltwins/digital-twins-core/review/digital-twins-core.api.md b/sdk/digitaltwins/digital-twins-core/review/digital-twins-core.api.md index 273517cadb88..48d4a7db1c78 100644 --- a/sdk/digitaltwins/digital-twins-core/review/digital-twins-core.api.md +++ b/sdk/digitaltwins/digital-twins-core/review/digital-twins-core.api.md @@ -40,26 +40,36 @@ export interface DigitalTwinsAddRelationshipOptionalParams extends coreClient.Op } // @public -export type DigitalTwinsAddRelationshipResponse = DigitalTwinsAddRelationshipHeaders & Record; +export type DigitalTwinsAddRelationshipResponse = DigitalTwinsAddRelationshipHeaders & { + [propertyName: string]: any; +}; // @public -export type DigitalTwinsAddResponse = DigitalTwinsAddHeaders & Record; +export type DigitalTwinsAddResponse = DigitalTwinsAddHeaders & { + [propertyName: string]: any; +}; // @public export class DigitalTwinsClient { constructor(endpointUrl: string, credential: TokenCredential, options?: DigitalTwinsClientOptions); + cancelImportJob(importJobId: string, options?: OperationOptions): Promise; createModels(dtdlModels: Array>, options?: OperationOptions): Promise; decomissionModel(modelId: string, options?: OperationOptions): Promise; deleteDigitalTwin(digitalTwinId: string, options?: DigitalTwinsDeleteOptionalParams): Promise; deleteEventRoute(eventRouteId: string, options?: OperationOptions): Promise; + deleteImportJob(importJobId: string, options?: OperationOptions): Promise; deleteModel(modelId: string, options?: OperationOptions): Promise; deleteRelationship(digitalTwinId: string, relationshipId: string, options?: DigitalTwinsDeleteRelationshipOptionalParams): Promise; getComponent(digitalTwinId: string, componentName: string, options?: OperationOptions): Promise; getDigitalTwin(digitalTwinId: string, options?: OperationOptions): Promise; getEventRoute(eventRouteId: string, options?: OperationOptions): Promise; + // Warning: (ae-forgotten-export) The symbol "ImportJob" needs to be exported by the entry point index.d.ts + getImportJob(importJobId: string, options?: OperationOptions): Promise; getModel(modelId: string, options?: GetModelOptions): Promise; getRelationship(digitalTwinId: string, relationshipId: string, options?: OperationOptions): Promise; listEventRoutes(options?: ListEventRoutesOptions): PagedAsyncIterableIterator; + // Warning: (ae-forgotten-export) The symbol "ImportJobsListOptionalParams" needs to be exported by the entry point index.d.ts + listImportJobs(options?: ImportJobsListOptionalParams): PagedAsyncIterableIterator; listIncomingRelationships(digitalTwinId: string, options?: ListIncomingRelationshipsOptions): PagedAsyncIterableIterator; listModels(options?: ListModelsOptions): PagedAsyncIterableIterator; listRelationships(digitalTwinId: string, options?: ListRelationshipsOptions): PagedAsyncIterableIterator>; @@ -71,6 +81,7 @@ export class DigitalTwinsClient { updateRelationship(digitalTwinId: string, relationshipId: string, jsonPatch: Array>, options?: DigitalTwinsUpdateRelationshipOptionalParams): Promise; upsertDigitalTwin(digitalTwinId: string, digitalTwinJson: string, options?: DigitalTwinsAddOptionalParams): Promise; upsertEventRoute(eventRouteId: string, endpointId: string, filter: string, options?: OperationOptions): Promise; + upsertImportJob(importJobId: string, inputBlobUri: string, outputBlobUri: string, options?: OperationOptions): Promise; upsertRelationship(digitalTwinId: string, relationshipId: string, relationship: Record, options?: DigitalTwinsAddRelationshipOptionalParams): Promise; } @@ -94,7 +105,9 @@ export interface DigitalTwinsGetByIdHeaders { } // @public -export type DigitalTwinsGetByIdResponse = DigitalTwinsGetByIdHeaders & Record; +export type DigitalTwinsGetByIdResponse = DigitalTwinsGetByIdHeaders & { + [propertyName: string]: any; +}; // @public export interface DigitalTwinsGetComponentHeaders { @@ -102,7 +115,9 @@ export interface DigitalTwinsGetComponentHeaders { } // @public -export type DigitalTwinsGetComponentResponse = DigitalTwinsGetComponentHeaders & Record; +export type DigitalTwinsGetComponentResponse = DigitalTwinsGetComponentHeaders & { + [propertyName: string]: any; +}; // @public export interface DigitalTwinsGetRelationshipByIdHeaders { @@ -110,7 +125,9 @@ export interface DigitalTwinsGetRelationshipByIdHeaders { } // @public -export type DigitalTwinsGetRelationshipByIdResponse = DigitalTwinsGetRelationshipByIdHeaders & Record; +export type DigitalTwinsGetRelationshipByIdResponse = DigitalTwinsGetRelationshipByIdHeaders & { + [propertyName: string]: any; +}; // @public export type DigitalTwinsListIncomingRelationshipsResponse = IncomingRelationshipCollection; @@ -181,7 +198,7 @@ export interface EventRoute { // @public export interface EventRouteCollection { nextLink?: string; - value?: EventRoute[]; + value: EventRoute[]; } // @public @@ -207,7 +224,7 @@ export interface IncomingRelationship { export interface IncomingRelationshipCollection { nextLink?: string; // (undocumented) - value?: IncomingRelationship[]; + value: IncomingRelationship[]; } // @public @@ -234,7 +251,7 @@ export interface ListRelationshipsOptions extends coreClient.OperationOptions { // @public export interface PagedDigitalTwinsModelDataCollection { nextLink?: string; - value?: DigitalTwinsModelData[]; + value: DigitalTwinsModelData[]; } // @public @@ -248,7 +265,7 @@ export type QueryQueryTwinsResponse = QueryQueryTwinsHeaders & QueryResult; // @public export interface QueryResult { continuationToken?: string; - value?: Record[]; + value: Record[]; } // @public @@ -265,7 +282,7 @@ export interface QueryTwinsOptions extends coreClient.OperationOptions { // @public export interface RelationshipCollection { nextLink?: string; - value?: Record[]; + value: Record[]; } // (No @packageDocumentation comment for this package) diff --git a/sdk/digitaltwins/digital-twins-core/swagger/README.md b/sdk/digitaltwins/digital-twins-core/swagger/README.md index 874f28016141..941026de1758 100644 --- a/sdk/digitaltwins/digital-twins-core/swagger/README.md +++ b/sdk/digitaltwins/digital-twins-core/swagger/README.md @@ -12,7 +12,7 @@ use-extension: generate-metadata: false add-credentials: false license-header: MICROSOFT_MIT_NO_VERSION -input-file: https://github.com/Azure/azure-rest-api-specs/blob/master/specification/digitaltwins/data-plane/Microsoft.DigitalTwins/stable/2020-10-31/digitaltwins.json +input-file: https://github.com/Azure/azure-rest-api-specs/blob/2c0f2c7d585b99af7428435aa065d5ea4276119a/specification/digitaltwins/data-plane/Microsoft.DigitalTwins/stable/2023-06-30/digitaltwins.json output-folder: ../ source-code-folder-path: ./src/generated package-version: 2.0.0