diff --git a/sdk/recoveryservices/arm-recoveryservices/LICENSE.txt b/sdk/recoveryservices/arm-recoveryservices/LICENSE.txt index ea8fb1516028..2d3163745319 100644 --- a/sdk/recoveryservices/arm-recoveryservices/LICENSE.txt +++ b/sdk/recoveryservices/arm-recoveryservices/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2020 Microsoft +Copyright (c) 2021 Microsoft Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/sdk/recoveryservices/arm-recoveryservices/README.md b/sdk/recoveryservices/arm-recoveryservices/README.md index 54336c35cd94..b572e4c37244 100644 --- a/sdk/recoveryservices/arm-recoveryservices/README.md +++ b/sdk/recoveryservices/arm-recoveryservices/README.md @@ -1,93 +1,101 @@ ## Azure RecoveryServicesClient SDK for JavaScript -This package contains an isomorphic SDK for RecoveryServicesClient. +This package contains an isomorphic SDK (runs both in node.js and in browsers) for RecoveryServicesClient. ### Currently supported environments -- Node.js version 6.x.x or higher -- Browser JavaScript +- [LTS versions of Node.js](https://nodejs.org/about/releases/) +- Latest versions of Safari, Chrome, Edge and Firefox. -### How to Install +### Prerequisites +You must have an [Azure subscription](https://azure.microsoft.com/free/). + +### How to install + +To use this SDK in your project, you will need to install two packages. +- `@azure/arm-recoveryservices` that contains the client. +- `@azure/identity` that provides different mechanisms for the client to authenticate your requests using Azure Active Directory. + +Install both packages using the below command: ```bash -npm install @azure/arm-recoveryservices +npm install --save @azure/arm-recoveryservices @azure/identity ``` +> **Note**: You may have used either `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` in the past. These packages are in maintenance mode receiving critical bug fixes, but no new features. +If you are on a [Node.js that has LTS status](https://nodejs.org/about/releases/), or are writing a client side browser application, we strongly encourage you to upgrade to `@azure/identity` which uses the latest versions of Azure Active Directory and MSAL APIs and provides more authentication options. ### How to use -#### nodejs - client creation and list replicationUsages as an example written in TypeScript. +- If you are writing a client side browser application, + - Follow the instructions in the section on Authenticating client side browser applications in [Azure Identity examples](https://aka.ms/azsdk/js/identity/examples) to register your application in the Microsoft identity platform and set the right permissions. + - Copy the client ID and tenant ID from the Overview section of your app registration in Azure portal and use it in the browser sample below. +- If you are writing a server side application, + - [Select a credential from `@azure/identity` based on the authentication method of your choice](https://aka.ms/azsdk/js/identity/examples) + - Complete the set up steps required by the credential if any. + - Use the credential you picked in the place of `DefaultAzureCredential` in the Node.js sample below. -##### Install @azure/ms-rest-nodeauth - -- Please install minimum version of `"@azure/ms-rest-nodeauth": "^3.0.0"`. -```bash -npm install @azure/ms-rest-nodeauth@"^3.0.0" -``` +In the below samples, we pass the credential and the Azure subscription id to instantiate the client. +Once the client is created, explore the operations on it either in your favorite editor or in our [API reference documentation](https://docs.microsoft.com/javascript/api) to get started. +#### nodejs - Authentication, client creation, and list replicationUsages as an example written in JavaScript. ##### Sample code -While the below sample uses the interactive login, other authentication options can be found in the [README.md file of @azure/ms-rest-nodeauth](https://www.npmjs.com/package/@azure/ms-rest-nodeauth) package -```typescript -const msRestNodeAuth = require("@azure/ms-rest-nodeauth"); +```javascript +const { DefaultAzureCredential } = require("@azure/identity"); const { RecoveryServicesClient } = require("@azure/arm-recoveryservices"); const subscriptionId = process.env["AZURE_SUBSCRIPTION_ID"]; -msRestNodeAuth.interactiveLogin().then((creds) => { - const client = new RecoveryServicesClient(creds, subscriptionId); - const resourceGroupName = "testresourceGroupName"; - const vaultName = "testvaultName"; - client.replicationUsages.list(resourceGroupName, vaultName).then((result) => { - console.log("The result is:"); - console.log(result); - }); +// Use `DefaultAzureCredential` or any other credential of your choice based on https://aka.ms/azsdk/js/identity/examples +// Please note that you can also use credentials from the `@azure/ms-rest-nodeauth` package instead. +const creds = new DefaultAzureCredential(); +const client = new RecoveryServicesClient(creds, subscriptionId); +const resourceGroupName = "testresourceGroupName"; +const vaultName = "testvaultName"; +client.replicationUsages.list(resourceGroupName, vaultName).then((result) => { + console.log("The result is:"); + console.log(result); }).catch((err) => { + console.log("An error occurred:"); console.error(err); }); ``` -#### browser - Authentication, client creation and list replicationUsages as an example written in JavaScript. +#### browser - Authentication, client creation, and list replicationUsages as an example written in JavaScript. -##### Install @azure/ms-rest-browserauth - -```bash -npm install @azure/ms-rest-browserauth -``` +In browser applications, we recommend using the `InteractiveBrowserCredential` that interactively authenticates using the default system browser. + - See [Single-page application: App registration guide](https://docs.microsoft.com/azure/active-directory/develop/scenario-spa-app-registration) to configure your app registration for the browser. + - Note down the client Id from the previous step and use it in the browser sample below. ##### Sample code -See https://github.com/Azure/ms-rest-browserauth to learn how to authenticate to Azure in the browser. - - index.html + ```html @azure/arm-recoveryservices sample - - + diff --git a/sdk/recoveryservices/arm-recoveryservices/package.json b/sdk/recoveryservices/arm-recoveryservices/package.json index 20376606d69b..a2cba30a58cc 100644 --- a/sdk/recoveryservices/arm-recoveryservices/package.json +++ b/sdk/recoveryservices/arm-recoveryservices/package.json @@ -4,8 +4,9 @@ "description": "RecoveryServicesClient Library with typescript type definitions for node.js and browser.", "version": "4.1.0", "dependencies": { - "@azure/ms-rest-azure-js": "^2.0.1", - "@azure/ms-rest-js": "^2.0.4", + "@azure/ms-rest-azure-js": "^2.1.0", + "@azure/ms-rest-js": "^2.2.0", + "@azure/core-auth": "^1.1.4", "tslib": "^1.10.0" }, "keywords": [ @@ -20,13 +21,13 @@ "module": "./esm/recoveryServicesClient.js", "types": "./esm/recoveryServicesClient.d.ts", "devDependencies": { - "typescript": "^3.5.3", + "typescript": "^3.6.0", "rollup": "^1.18.0", "rollup-plugin-node-resolve": "^5.2.0", "rollup-plugin-sourcemaps": "^0.4.2", "uglify-js": "^3.6.0" }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/recoveryservices/arm-recoveryservices", + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/recoveryservices/arm-recoveryservices", "repository": { "type": "git", "url": "https://github.com/Azure/azure-sdk-for-js.git" diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/index.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/index.ts index 38ce19130963..f0ddbd870721 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/index.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/index.ts @@ -140,6 +140,10 @@ export interface ResourceCertificateAndAadDetails { * Azure Management Endpoint Audience. */ azureManagementEndpointAudience: string; + /** + * Service Resource Id. + */ + serviceResourceId?: string; } /** @@ -426,7 +430,7 @@ export interface Resource extends BaseResource { /** * Optional ETag. */ - eTag?: string; + etag?: string; } /** @@ -437,6 +441,10 @@ export interface Sku { * The Sku name. Possible values include: 'Standard', 'RS0' */ name: SkuName; + /** + * The Sku tier. + */ + tier?: string; } /** @@ -520,6 +528,22 @@ export interface UpgradeDetails { readonly previousResourceId?: string; } +/** + * A resource identity that is managed by the user of the service. + */ +export interface UserIdentity { + /** + * The principal ID of the user-assigned identity. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly principalId?: string; + /** + * The client ID of the user-assigned identity. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly clientId?: string; +} + /** * Identity for the resource. */ @@ -535,9 +559,18 @@ export interface IdentityData { */ readonly tenantId?: string; /** - * The identity type. Possible values include: 'SystemAssigned', 'None' + * The type of managed identity used. The type 'SystemAssigned, UserAssigned' includes both an + * implicitly created identity and a set of user-assigned identities. The type 'None' will remove + * any identities. Possible values include: 'SystemAssigned', 'None', 'UserAssigned', + * 'SystemAssigned, UserAssigned' */ type: ResourceIdentityType; + /** + * The list of user-assigned identities associated with the resource. The user-assigned identity + * dictionary keys will be ARM resource ids in the form: + * '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + */ + userAssignedIdentities?: { [propertyName: string]: UserIdentity }; } /** @@ -600,6 +633,44 @@ export interface PrivateEndpointConnectionVaultProperties { properties?: PrivateEndpointConnection; } +/** + * The properties of the Key Vault which hosts CMK + */ +export interface CmkKeyVaultProperties { + /** + * The key uri of the Customer Managed Key + */ + keyUri?: string; +} + +/** + * The details of the identity used for CMK + */ +export interface CmkKekIdentity { + /** + * Indicate that system assigned identity should be used. Mutually exclusive with + * 'userAssignedIdentity' field + */ + useSystemAssignedIdentity?: boolean; + /** + * The user assigned identity to be used to grant permissions in case the type of identity used + * is UserAssigned + */ + userAssignedIdentity?: string; +} + +/** + * Customer Managed Key details of the resource. + */ +export interface VaultPropertiesEncryption { + keyVaultProperties?: CmkKeyVaultProperties; + kekIdentity?: CmkKekIdentity; + /** + * Enabling/Disabling the Double Encryption state. Possible values include: 'Enabled', 'Disabled' + */ + infrastructureEncryption?: InfrastructureEncryptionState; +} + /** * Properties of the vault. */ @@ -625,6 +696,42 @@ export interface VaultProperties { * **NOTE: This property will not be serialized. It can only be populated by the server.** */ readonly privateEndpointStateForSiteRecovery?: VaultPrivateEndpointState; + /** + * Customer Managed Key details of the resource. + */ + encryption?: VaultPropertiesEncryption; +} + +/** + * Metadata pertaining to creation and last modification of the resource. + */ +export interface SystemData { + /** + * The identity that created the resource. + */ + createdBy?: string; + /** + * The type of identity that created the resource. Possible values include: 'User', + * 'Application', 'ManagedIdentity', 'Key' + */ + createdByType?: CreatedByType; + /** + * The timestamp of resource creation (UTC). + */ + createdAt?: Date; + /** + * The identity that last modified the resource. + */ + lastModifiedBy?: string; + /** + * The type of identity that last modified the resource. Possible values include: 'User', + * 'Application', 'ManagedIdentity', 'Key' + */ + lastModifiedByType?: CreatedByType; + /** + * The type of identity that last modified the resource. + */ + lastModifiedAt?: Date; } /** @@ -634,6 +741,7 @@ export interface Vault extends TrackedResource { identity?: IdentityData; properties?: VaultProperties; sku?: Sku; + systemData?: SystemData; } /** @@ -704,6 +812,85 @@ export interface PrivateLinkResource { readonly type?: string; } +/** + * The resource management error additional info. + */ +export interface ErrorAdditionalInfo { + /** + * The additional info. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly info?: any; + /** + * The additional info type. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly type?: string; +} + +/** + * The resource management error response. + */ +export interface ErrorModel { + /** + * The error additional info. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly additionalInfo?: ErrorAdditionalInfo[]; + /** + * The error code. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly code?: string; + /** + * The error details. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly details?: ErrorModel[]; + /** + * The error message. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly message?: string; + /** + * The error target. + * **NOTE: This property will not be serialized. It can only be populated by the server.** + */ + readonly target?: string; +} + +/** + * Operation Resource + */ +export interface OperationResource { + /** + * End time of the operation + */ + endTime?: Date; + /** + * Required if status == failed or status == canceled. This is the OData v4 error format, used by + * the RPC and will go into the v2.2 Azure REST API guidelines. + */ + error?: ErrorModel; + /** + * It should match what is used to GET the operation result + */ + id?: string; + /** + * It must match the last segment of the "id" field, and will typically be a GUID / system + * generated value + */ + name?: string; + /** + * The status of the operation. (InProgress/Success/Failed/Cancelled) + */ + status?: string; + /** + * Start time of the operation + */ + startTime?: Date; +} + /** * The name of usage. */ @@ -842,11 +1029,12 @@ export type TriggerType = 'UserTriggered' | 'ForcedUpgrade'; /** * Defines values for ResourceIdentityType. - * Possible values include: 'SystemAssigned', 'None' + * Possible values include: 'SystemAssigned', 'None', 'UserAssigned', 'SystemAssigned, + * UserAssigned' * @readonly * @enum {string} */ -export type ResourceIdentityType = 'SystemAssigned' | 'None'; +export type ResourceIdentityType = 'SystemAssigned' | 'None' | 'UserAssigned' | 'SystemAssigned, UserAssigned'; /** * Defines values for ProvisioningState. @@ -872,6 +1060,22 @@ export type PrivateEndpointConnectionStatus = 'Pending' | 'Approved' | 'Rejected */ export type VaultPrivateEndpointState = 'None' | 'Enabled'; +/** + * Defines values for InfrastructureEncryptionState. + * Possible values include: 'Enabled', 'Disabled' + * @readonly + * @enum {string} + */ +export type InfrastructureEncryptionState = 'Enabled' | 'Disabled'; + +/** + * Defines values for CreatedByType. + * Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' + * @readonly + * @enum {string} + */ +export type CreatedByType = 'User' | 'Application' | 'ManagedIdentity' | 'Key'; + /** * Defines values for UsagesUnit. * Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountPerSecond', @@ -1101,6 +1305,46 @@ export type VaultsUpdateResponse = Vault & { }; }; +/** + * Contains response data for the beginCreateOrUpdate operation. + */ +export type VaultsBeginCreateOrUpdateResponse = Vault & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Vault; + }; +}; + +/** + * Contains response data for the beginUpdate operation. + */ +export type VaultsBeginUpdateResponse = Vault & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Vault; + }; +}; + /** * Contains response data for the listBySubscriptionIdNext operation. */ @@ -1241,6 +1485,46 @@ export type VaultExtendedInfoUpdateResponse = VaultExtendedInfoResource & { }; }; +/** + * Contains response data for the getOperationStatus operation. + */ +export type GetOperationStatusResponse = OperationResource & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: OperationResource; + }; +}; + +/** + * Contains response data for the getOperationResult operation. + */ +export type GetOperationResultResponse = Vault & { + /** + * The underlying HTTP response. + */ + _response: msRest.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: Vault; + }; +}; + /** * Contains response data for the listByVaults operation. */ diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/mappers.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/mappers.ts index f3645eb5e803..80bd3b0515e6 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/mappers.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/mappers.ts @@ -164,6 +164,12 @@ export const ResourceCertificateAndAadDetails: msRest.CompositeMapper = { type: { name: "String" } + }, + serviceResourceId: { + serializedName: "serviceResourceId", + type: { + name: "String" + } } } } @@ -577,8 +583,8 @@ export const Resource: msRest.CompositeMapper = { name: "String" } }, - eTag: { - serializedName: "eTag", + etag: { + serializedName: "etag", type: { name: "String" } @@ -599,6 +605,12 @@ export const Sku: msRest.CompositeMapper = { type: { name: "String" } + }, + tier: { + serializedName: "tier", + type: { + name: "String" + } } } } @@ -734,6 +746,30 @@ export const UpgradeDetails: msRest.CompositeMapper = { } }; +export const UserIdentity: msRest.CompositeMapper = { + serializedName: "UserIdentity", + type: { + name: "Composite", + className: "UserIdentity", + modelProperties: { + principalId: { + readOnly: true, + serializedName: "principalId", + type: { + name: "String" + } + }, + clientId: { + readOnly: true, + serializedName: "clientId", + type: { + name: "String" + } + } + } + } +}; + export const IdentityData: msRest.CompositeMapper = { serializedName: "IdentityData", type: { @@ -760,6 +796,18 @@ export const IdentityData: msRest.CompositeMapper = { type: { name: "String" } + }, + userAssignedIdentities: { + serializedName: "userAssignedIdentities", + type: { + name: "Dictionary", + value: { + type: { + name: "Composite", + className: "UserIdentity" + } + } + } } } } @@ -868,6 +916,74 @@ export const PrivateEndpointConnectionVaultProperties: msRest.CompositeMapper = } }; +export const CmkKeyVaultProperties: msRest.CompositeMapper = { + serializedName: "CmkKeyVaultProperties", + type: { + name: "Composite", + className: "CmkKeyVaultProperties", + modelProperties: { + keyUri: { + serializedName: "keyUri", + type: { + name: "String" + } + } + } + } +}; + +export const CmkKekIdentity: msRest.CompositeMapper = { + serializedName: "CmkKekIdentity", + type: { + name: "Composite", + className: "CmkKekIdentity", + modelProperties: { + useSystemAssignedIdentity: { + serializedName: "useSystemAssignedIdentity", + type: { + name: "Boolean" + } + }, + userAssignedIdentity: { + serializedName: "userAssignedIdentity", + type: { + name: "String" + } + } + } + } +}; + +export const VaultPropertiesEncryption: msRest.CompositeMapper = { + serializedName: "VaultProperties_encryption", + type: { + name: "Composite", + className: "VaultPropertiesEncryption", + modelProperties: { + keyVaultProperties: { + serializedName: "keyVaultProperties", + type: { + name: "Composite", + className: "CmkKeyVaultProperties" + } + }, + kekIdentity: { + serializedName: "kekIdentity", + type: { + name: "Composite", + className: "CmkKekIdentity" + } + }, + infrastructureEncryption: { + serializedName: "infrastructureEncryption", + type: { + name: "String" + } + } + } + } +}; + export const VaultProperties: msRest.CompositeMapper = { serializedName: "VaultProperties", type: { @@ -914,6 +1030,59 @@ export const VaultProperties: msRest.CompositeMapper = { type: { name: "String" } + }, + encryption: { + serializedName: "encryption", + type: { + name: "Composite", + className: "VaultPropertiesEncryption" + } + } + } + } +}; + +export const SystemData: msRest.CompositeMapper = { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData", + modelProperties: { + createdBy: { + serializedName: "createdBy", + type: { + name: "String" + } + }, + createdByType: { + serializedName: "createdByType", + type: { + name: "String" + } + }, + createdAt: { + serializedName: "createdAt", + type: { + name: "DateTime" + } + }, + lastModifiedBy: { + serializedName: "lastModifiedBy", + type: { + name: "String" + } + }, + lastModifiedByType: { + serializedName: "lastModifiedByType", + type: { + name: "String" + } + }, + lastModifiedAt: { + serializedName: "lastModifiedAt", + type: { + name: "DateTime" + } } } } @@ -946,6 +1115,13 @@ export const Vault: msRest.CompositeMapper = { name: "Composite", className: "Sku" } + }, + systemData: { + serializedName: "systemData", + type: { + name: "Composite", + className: "SystemData" + } } } } @@ -1080,6 +1256,134 @@ export const PrivateLinkResource: msRest.CompositeMapper = { } }; +export const ErrorAdditionalInfo: msRest.CompositeMapper = { + serializedName: "ErrorAdditionalInfo", + type: { + name: "Composite", + className: "ErrorAdditionalInfo", + modelProperties: { + info: { + readOnly: true, + serializedName: "info", + type: { + name: "Object" + } + }, + type: { + readOnly: true, + serializedName: "type", + type: { + name: "String" + } + } + } + } +}; + +export const ErrorModel: msRest.CompositeMapper = { + serializedName: "Error", + type: { + name: "Composite", + className: "ErrorModel", + modelProperties: { + additionalInfo: { + readOnly: true, + serializedName: "additionalInfo", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorAdditionalInfo" + } + } + } + }, + code: { + readOnly: true, + serializedName: "code", + type: { + name: "String" + } + }, + details: { + readOnly: true, + serializedName: "details", + type: { + name: "Sequence", + element: { + type: { + name: "Composite", + className: "ErrorModel" + } + } + } + }, + message: { + readOnly: true, + serializedName: "message", + type: { + name: "String" + } + }, + target: { + readOnly: true, + serializedName: "target", + type: { + name: "String" + } + } + } + } +}; + +export const OperationResource: msRest.CompositeMapper = { + serializedName: "OperationResource", + type: { + name: "Composite", + className: "OperationResource", + modelProperties: { + endTime: { + serializedName: "endTime", + type: { + name: "DateTime" + } + }, + error: { + serializedName: "error", + type: { + name: "Composite", + className: "ErrorModel" + } + }, + id: { + serializedName: "id", + type: { + name: "String" + } + }, + name: { + serializedName: "name", + type: { + name: "String" + } + }, + status: { + serializedName: "status", + type: { + name: "String" + } + }, + startTime: { + serializedName: "startTime", + type: { + name: "DateTime" + } + } + } + } +}; + export const NameInfo: msRest.CompositeMapper = { serializedName: "NameInfo", type: { diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/operationsMappers.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/operationsMappers.ts index cf239cd893a5..b503924f7fba 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/operationsMappers.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/operationsMappers.ts @@ -14,5 +14,7 @@ export { ClientDiscoveryForServiceSpecification, ClientDiscoveryResponse, ClientDiscoveryValueForSingleApi, - CloudError + CloudError, + ErrorAdditionalInfo, + ErrorModel } from "../models/mappers"; diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/parameters.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/parameters.ts index 7c4f3dbc4093..0da842c17473 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/parameters.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/parameters.ts @@ -70,6 +70,16 @@ export const nextPageLink: msRest.OperationURLParameter = { }, skipEncoding: true }; +export const operationId: msRest.OperationURLParameter = { + parameterPath: "operationId", + mapper: { + required: true, + serializedName: "operationId", + type: { + name: "String" + } + } +}; export const privateLinkResourceName: msRest.OperationURLParameter = { parameterPath: "privateLinkResourceName", mapper: { diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/privateLinkResourcesOperationsMappers.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/privateLinkResourcesOperationsMappers.ts index 8b1a986c0039..f9201672ed2f 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/privateLinkResourcesOperationsMappers.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/privateLinkResourcesOperationsMappers.ts @@ -9,6 +9,8 @@ export { discriminators, CloudError, + ErrorAdditionalInfo, + ErrorModel, PrivateLinkResource, PrivateLinkResources } from "../models/mappers"; diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/recoveryServicesMappers.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/recoveryServicesMappers.ts index 665c4167517e..1e2e76caa085 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/recoveryServicesMappers.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/recoveryServicesMappers.ts @@ -10,5 +10,7 @@ export { discriminators, CheckNameAvailabilityParameters, CheckNameAvailabilityResult, - CloudError + CloudError, + ErrorAdditionalInfo, + ErrorModel } from "../models/mappers"; diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/vaultCertificatesMappers.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/vaultCertificatesMappers.ts index 038a0ef44654..6edf1f3ecf54 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/vaultCertificatesMappers.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/vaultCertificatesMappers.ts @@ -11,6 +11,8 @@ export { BaseResource, CertificateRequest, CloudError, + CmkKekIdentity, + CmkKeyVaultProperties, IdentityData, PatchTrackedResource, PatchVault, @@ -24,10 +26,13 @@ export { ResourceCertificateAndAcsDetails, ResourceCertificateDetails, Sku, + SystemData, TrackedResource, UpgradeDetails, + UserIdentity, Vault, VaultCertificateResponse, VaultExtendedInfoResource, - VaultProperties + VaultProperties, + VaultPropertiesEncryption } from "../models/mappers"; diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/vaultExtendedInfoOperationsMappers.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/vaultExtendedInfoOperationsMappers.ts index cbdfd07cd245..148ce456fcca 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/vaultExtendedInfoOperationsMappers.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/vaultExtendedInfoOperationsMappers.ts @@ -10,6 +10,10 @@ export { discriminators, BaseResource, CloudError, + CmkKekIdentity, + CmkKeyVaultProperties, + ErrorAdditionalInfo, + ErrorModel, IdentityData, PatchTrackedResource, PatchVault, @@ -22,10 +26,13 @@ export { ResourceCertificateAndAcsDetails, ResourceCertificateDetails, Sku, + SystemData, TrackedResource, UpgradeDetails, + UserIdentity, Vault, VaultCertificateResponse, VaultExtendedInfoResource, - VaultProperties + VaultProperties, + VaultPropertiesEncryption } from "../models/mappers"; diff --git a/sdk/recoveryservices/arm-recoveryservices/src/models/vaultsMappers.ts b/sdk/recoveryservices/arm-recoveryservices/src/models/vaultsMappers.ts index 9daea6407eac..ade64458d488 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/models/vaultsMappers.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/models/vaultsMappers.ts @@ -10,6 +10,10 @@ export { discriminators, BaseResource, CloudError, + CmkKekIdentity, + CmkKeyVaultProperties, + ErrorAdditionalInfo, + ErrorModel, IdentityData, PatchTrackedResource, PatchVault, @@ -22,11 +26,14 @@ export { ResourceCertificateAndAcsDetails, ResourceCertificateDetails, Sku, + SystemData, TrackedResource, UpgradeDetails, + UserIdentity, Vault, VaultCertificateResponse, VaultExtendedInfoResource, VaultList, - VaultProperties + VaultProperties, + VaultPropertiesEncryption } from "../models/mappers"; diff --git a/sdk/recoveryservices/arm-recoveryservices/src/operations/vaults.ts b/sdk/recoveryservices/arm-recoveryservices/src/operations/vaults.ts index 969d6f0b82fa..baa38e377c53 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/operations/vaults.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/operations/vaults.ts @@ -8,6 +8,7 @@ */ import * as msRest from "@azure/ms-rest-js"; +import * as msRestAzure from "@azure/ms-rest-azure-js"; import * as Models from "../models"; import * as Mappers from "../models/vaultsMappers"; import * as Parameters from "../models/parameters"; @@ -124,34 +125,9 @@ export class Vaults { * @param [options] The optional parameters * @returns Promise */ - createOrUpdate(resourceGroupName: string, vaultName: string, vault: Models.Vault, options?: msRest.RequestOptionsBase): Promise; - /** - * @param resourceGroupName The name of the resource group where the recovery services vault is - * present. - * @param vaultName The name of the recovery services vault. - * @param vault Recovery Services Vault to be created. - * @param callback The callback - */ - createOrUpdate(resourceGroupName: string, vaultName: string, vault: Models.Vault, callback: msRest.ServiceCallback): void; - /** - * @param resourceGroupName The name of the resource group where the recovery services vault is - * present. - * @param vaultName The name of the recovery services vault. - * @param vault Recovery Services Vault to be created. - * @param options The optional parameters - * @param callback The callback - */ - createOrUpdate(resourceGroupName: string, vaultName: string, vault: Models.Vault, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - createOrUpdate(resourceGroupName: string, vaultName: string, vault: Models.Vault, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( - { - resourceGroupName, - vaultName, - vault, - options - }, - createOrUpdateOperationSpec, - callback) as Promise; + createOrUpdate(resourceGroupName: string, vaultName: string, vault: Models.Vault, options?: msRest.RequestOptionsBase): Promise { + return this.beginCreateOrUpdate(resourceGroupName,vaultName,vault,options) + .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; } /** @@ -198,34 +174,51 @@ export class Vaults { * @param [options] The optional parameters * @returns Promise */ - update(resourceGroupName: string, vaultName: string, vault: Models.PatchVault, options?: msRest.RequestOptionsBase): Promise; + update(resourceGroupName: string, vaultName: string, vault: Models.PatchVault, options?: msRest.RequestOptionsBase): Promise { + return this.beginUpdate(resourceGroupName,vaultName,vault,options) + .then(lroPoller => lroPoller.pollUntilFinished()) as Promise; + } + /** + * Creates or updates a Recovery Services vault. * @param resourceGroupName The name of the resource group where the recovery services vault is * present. * @param vaultName The name of the recovery services vault. * @param vault Recovery Services Vault to be created. - * @param callback The callback + * @param [options] The optional parameters + * @returns Promise */ - update(resourceGroupName: string, vaultName: string, vault: Models.PatchVault, callback: msRest.ServiceCallback): void; + beginCreateOrUpdate(resourceGroupName: string, vaultName: string, vault: Models.Vault, options?: msRest.RequestOptionsBase): Promise { + return this.client.sendLRORequest( + { + resourceGroupName, + vaultName, + vault, + options + }, + beginCreateOrUpdateOperationSpec, + options); + } + /** + * Updates the vault. * @param resourceGroupName The name of the resource group where the recovery services vault is * present. * @param vaultName The name of the recovery services vault. * @param vault Recovery Services Vault to be created. - * @param options The optional parameters - * @param callback The callback + * @param [options] The optional parameters + * @returns Promise */ - update(resourceGroupName: string, vaultName: string, vault: Models.PatchVault, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; - update(resourceGroupName: string, vaultName: string, vault: Models.PatchVault, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { - return this.client.sendOperationRequest( + beginUpdate(resourceGroupName: string, vaultName: string, vault: Models.PatchVault, options?: msRest.RequestOptionsBase): Promise { + return this.client.sendLRORequest( { resourceGroupName, vaultName, vault, options }, - updateOperationSpec, - callback) as Promise; + beginUpdateOperationSpec, + options); } /** @@ -359,8 +352,8 @@ const getOperationSpec: msRest.OperationSpec = { serializer }; -const createOrUpdateOperationSpec: msRest.OperationSpec = { - httpMethod: "PUT", +const deleteMethodOperationSpec: msRest.OperationSpec = { + httpMethod: "DELETE", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}", urlParameters: [ Parameters.subscriptionId, @@ -373,20 +366,8 @@ const createOrUpdateOperationSpec: msRest.OperationSpec = { headerParameters: [ Parameters.acceptLanguage ], - requestBody: { - parameterPath: "vault", - mapper: { - ...Mappers.Vault, - required: true - } - }, responses: { - 200: { - bodyMapper: Mappers.Vault - }, - 201: { - bodyMapper: Mappers.Vault - }, + 200: {}, default: { bodyMapper: Mappers.CloudError } @@ -394,8 +375,8 @@ const createOrUpdateOperationSpec: msRest.OperationSpec = { serializer }; -const deleteMethodOperationSpec: msRest.OperationSpec = { - httpMethod: "DELETE", +const beginCreateOrUpdateOperationSpec: msRest.OperationSpec = { + httpMethod: "PUT", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}", urlParameters: [ Parameters.subscriptionId, @@ -408,8 +389,20 @@ const deleteMethodOperationSpec: msRest.OperationSpec = { headerParameters: [ Parameters.acceptLanguage ], + requestBody: { + parameterPath: "vault", + mapper: { + ...Mappers.Vault, + required: true + } + }, responses: { - 200: {}, + 200: { + bodyMapper: Mappers.Vault + }, + 201: { + bodyMapper: Mappers.Vault + }, default: { bodyMapper: Mappers.CloudError } @@ -417,7 +410,7 @@ const deleteMethodOperationSpec: msRest.OperationSpec = { serializer }; -const updateOperationSpec: msRest.OperationSpec = { +const beginUpdateOperationSpec: msRest.OperationSpec = { httpMethod: "PATCH", path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}", urlParameters: [ @@ -442,9 +435,7 @@ const updateOperationSpec: msRest.OperationSpec = { 200: { bodyMapper: Mappers.Vault }, - 201: { - bodyMapper: Mappers.Vault - }, + 202: {}, default: { bodyMapper: Mappers.CloudError } diff --git a/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.ts b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.ts index 7e1df780c2ed..83fe1d5c0d10 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClient.ts @@ -8,8 +8,10 @@ */ import * as msRest from "@azure/ms-rest-js"; +import { TokenCredential } from "@azure/core-auth"; import * as Models from "./models"; import * as Mappers from "./models/mappers"; +import * as Parameters from "./models/parameters"; import * as operations from "./operations"; import { RecoveryServicesClientContext } from "./recoveryServicesClientContext"; @@ -28,11 +30,16 @@ class RecoveryServicesClient extends RecoveryServicesClientContext { /** * Initializes a new instance of the RecoveryServicesClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription Id. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { super(credentials, subscriptionId, options); this.vaultCertificates = new operations.VaultCertificates(this); this.registeredIdentities = new operations.RegisteredIdentities(this); @@ -44,9 +51,140 @@ class RecoveryServicesClient extends RecoveryServicesClientContext { this.vaultExtendedInfo = new operations.VaultExtendedInfoOperations(this); this.usages = new operations.Usages(this); } + + /** + * Gets the operation status for a resource. + * @param resourceGroupName The name of the resource group where the recovery services vault is + * present. + * @param vaultName The name of the recovery services vault. + * @param operationId + * @param [options] The optional parameters + * @returns Promise + */ + getOperationStatus(resourceGroupName: string, vaultName: string, operationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group where the recovery services vault is + * present. + * @param vaultName The name of the recovery services vault. + * @param operationId + * @param callback The callback + */ + getOperationStatus(resourceGroupName: string, vaultName: string, operationId: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group where the recovery services vault is + * present. + * @param vaultName The name of the recovery services vault. + * @param operationId + * @param options The optional parameters + * @param callback The callback + */ + getOperationStatus(resourceGroupName: string, vaultName: string, operationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getOperationStatus(resourceGroupName: string, vaultName: string, operationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + resourceGroupName, + vaultName, + operationId, + options + }, + getOperationStatusOperationSpec, + callback) as Promise; + } + + /** + * Gets the operation result for a resource. + * @param resourceGroupName The name of the resource group where the recovery services vault is + * present. + * @param vaultName The name of the recovery services vault. + * @param operationId + * @param [options] The optional parameters + * @returns Promise + */ + getOperationResult(resourceGroupName: string, vaultName: string, operationId: string, options?: msRest.RequestOptionsBase): Promise; + /** + * @param resourceGroupName The name of the resource group where the recovery services vault is + * present. + * @param vaultName The name of the recovery services vault. + * @param operationId + * @param callback The callback + */ + getOperationResult(resourceGroupName: string, vaultName: string, operationId: string, callback: msRest.ServiceCallback): void; + /** + * @param resourceGroupName The name of the resource group where the recovery services vault is + * present. + * @param vaultName The name of the recovery services vault. + * @param operationId + * @param options The optional parameters + * @param callback The callback + */ + getOperationResult(resourceGroupName: string, vaultName: string, operationId: string, options: msRest.RequestOptionsBase, callback: msRest.ServiceCallback): void; + getOperationResult(resourceGroupName: string, vaultName: string, operationId: string, options?: msRest.RequestOptionsBase | msRest.ServiceCallback, callback?: msRest.ServiceCallback): Promise { + return this.sendOperationRequest( + { + resourceGroupName, + vaultName, + operationId, + options + }, + getOperationResultOperationSpec, + callback) as Promise; + } } // Operation Specifications +const serializer = new msRest.Serializer(Mappers); +const getOperationStatusOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/operationStatus/{operationId}", + urlParameters: [ + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.vaultName, + Parameters.operationId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.OperationResource + }, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; + +const getOperationResultOperationSpec: msRest.OperationSpec = { + httpMethod: "GET", + path: "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{vaultName}/operationResults/{operationId}", + urlParameters: [ + Parameters.subscriptionId, + Parameters.resourceGroupName, + Parameters.vaultName, + Parameters.operationId + ], + queryParameters: [ + Parameters.apiVersion + ], + headerParameters: [ + Parameters.acceptLanguage + ], + responses: { + 200: { + bodyMapper: Mappers.Vault + }, + 202: {}, + default: { + bodyMapper: Mappers.CloudError + } + }, + serializer +}; export { RecoveryServicesClient, diff --git a/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.ts b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.ts index 01afef1bd386..6f08dfa22159 100644 --- a/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.ts +++ b/sdk/recoveryservices/arm-recoveryservices/src/recoveryServicesClientContext.ts @@ -10,22 +10,28 @@ import * as Models from "./models"; import * as msRest from "@azure/ms-rest-js"; import * as msRestAzure from "@azure/ms-rest-azure-js"; +import { TokenCredential } from "@azure/core-auth"; const packageName = "@azure/arm-recoveryservices"; const packageVersion = "4.1.0"; export class RecoveryServicesClientContext extends msRestAzure.AzureServiceClient { - credentials: msRest.ServiceClientCredentials; + credentials: msRest.ServiceClientCredentials | TokenCredential; subscriptionId: string; apiVersion?: string; /** * Initializes a new instance of the RecoveryServicesClient class. - * @param credentials Credentials needed for the client to connect to Azure. + * @param credentials Credentials needed for the client to connect to Azure. Credentials + * implementing the TokenCredential interface from the @azure/identity package are recommended. For + * more information about these credentials, see + * {@link https://www.npmjs.com/package/@azure/identity}. Credentials implementing the + * ServiceClientCredentials interface from the older packages @azure/ms-rest-nodeauth and + * @azure/ms-rest-browserauth are also supported. * @param subscriptionId The subscription Id. * @param [options] The parameter options */ - constructor(credentials: msRest.ServiceClientCredentials, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { + constructor(credentials: msRest.ServiceClientCredentials | TokenCredential, subscriptionId: string, options?: Models.RecoveryServicesClientOptions) { if (credentials == undefined) { throw new Error('\'credentials\' cannot be null.'); } @@ -36,14 +42,14 @@ export class RecoveryServicesClientContext extends msRestAzure.AzureServiceClien if (!options) { options = {}; } - if(!options.userAgent) { + if (!options.userAgent) { const defaultUserAgent = msRestAzure.getDefaultUserAgentValue(); options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`; } super(credentials, options); - this.apiVersion = '2016-06-01'; + this.apiVersion = '2021-03-01'; this.acceptLanguage = 'en-US'; this.longRunningOperationRetryTimeout = 30; this.baseUri = options.baseUri || this.baseUri || "https://management.azure.com"; @@ -51,10 +57,10 @@ export class RecoveryServicesClientContext extends msRestAzure.AzureServiceClien this.credentials = credentials; this.subscriptionId = subscriptionId; - if(options.acceptLanguage !== null && options.acceptLanguage !== undefined) { + if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) { this.acceptLanguage = options.acceptLanguage; } - if(options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { + if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) { this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout; } }