Skip to content

Commit

Permalink
CodeGen from PR 17055 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Add `x-ms-enum` extension to keyvault (Azure#17055)

* fix

* make these two sealed enums
  • Loading branch information
SDKAuto committed Jan 5, 2022
1 parent dbbce26 commit cfde187
Show file tree
Hide file tree
Showing 31 changed files with 452 additions and 400 deletions.
113 changes: 58 additions & 55 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

27 changes: 6 additions & 21 deletions sdk/keyvault/arm-keyvault/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
# Release History

## 2.0.0-beta.2 (2022-01-05)

## 2.0.0-beta.2 (Unreleased)
The package of @azure/arm-keyvault is using our next generation design principles since version 2.0.0-beta.2, which contains breaking changes.

### Features Added
To understand the detail of the change, please refer to [Changelog](https://aka.ms/js-track2-changelog).

### Breaking Changes
To migrate the existing applications to the latest version, please refer to [Migration Guide](https://aka.ms/js-track2-migration-guide).

### Bugs Fixed

### Other Changes

## 2.0.0-beta.1 (2021-10-09)

This is the first preview for the new version of the `@azure/arm-keyvault` package that follows the new [guidelines for TypeScript SDKs](https://azure.github.io/azure-sdk/typescript_introduction.html) for Azure services.

While this package remains auto generated, the SDK generator itself has undergone changes to comply with the above guidelines in order to generate packages that are idiomatic to the JavaScript/TypeScript ecosystem and consistent with other packages for Azure services. For more on this, please see [State of the Azure SDK 2021](https://devblogs.microsoft.com/azure-sdk/state-of-the-azure-sdk-2021/).

Please note that this version has breaking changes, all of which were made after careful consideration during the authoring of the guidelines and user studies.

**Noteworthy changes and features**
- Authentication: The packages `@azure/ms-rest-nodeauth` or `@azure/ms-rest-browserauth` are no longer supported. Use package [@azure/identity](https://www.npmjs.com/package/@azure/identity) instead. Select a credential from Azure Identity examples based on the authentication method of your choice.
- Callbacks: Method overloads that used callbacks have been removed and the use of promises is encouraged instead.
- List operations now return an iterable result that follows the `PagedAsyncIterableIterator` interface as opposed to the previous model where you had to make a new request using the link to the next page.
- Long running operations i.e. the Lro related object returned by methods whose names started with `begin`, now uses `pollUntilDone` to check whether the request is finished, instead of `pollUntilFinished`. To get the final result, use the corresponding method that will have the suffix `AndWait`.
- The SDK only supports ECMAScript 2015 (ES6) and beyond, all projects that referenced this SDK should be upgraded to use ES6.
To learn more, please refer to our documentation [Quick Start](https://aka.ms/js-track2-quickstart).
2 changes: 1 addition & 1 deletion sdk/keyvault/arm-keyvault/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Microsoft
Copyright (c) 2022 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
Expand Down
14 changes: 8 additions & 6 deletions sdk/keyvault/arm-keyvault/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

This package contains an isomorphic SDK (runs both in Node.js and in browsers) for Azure KeyVaultManagement client.

You can also follow this [link](https://github.com/Azure/azure-sdk-for-js/tree/feature/v4/sdk/keyvault/arm-keyvault) to see the previous stable versions for this package. Note that they might not implement the guidelines(https://azure.github.io/azure-sdk/typescript_introduction.html) or have the same feature set as the new releases.

The Azure management API provides a RESTful set of web services that interact with Azure Key Vault.

[Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault) |
[Package (NPM)](https://www.npmjs.com/package/@azure/arm-keyvault) |
[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-keyvault) |
[API reference documentation](https://docs.microsoft.com/javascript/api/@azure/arm-keyvault?view=azure-node-preview) |
[Samples](https://github.com/Azure-Samples/azure-samples-js-management)

## Getting started
Expand All @@ -35,9 +33,9 @@ npm install @azure/arm-keyvault
To create a client object to access the Azure KeyVaultManagement API, you will need the `endpoint` of your Azure KeyVaultManagement resource and a `credential`. The Azure KeyVaultManagement client can use Azure Active Directory credentials to authenticate.
You can find the endpoint for your Azure KeyVaultManagement resource in the [Azure Portal][azure_portal].

#### Using an Azure Active Directory Credential
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token).

You can authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package:
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the `@azure/identity` package:

```bash
npm install @azure/identity
Expand All @@ -55,6 +53,10 @@ const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new KeyVaultManagementClient(new DefaultAzureCredential(), subscriptionId);
```


### JavaScript Bundle
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).

## Key concepts

### KeyVaultManagementClient
Expand All @@ -68,7 +70,7 @@ const client = new KeyVaultManagementClient(new DefaultAzureCredential(), subscr
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:

```javascript
import { setLogLevel } from "@azure/logger";
const { setLogLevel } = require("@azure/logger");
setLogLevel("info");
```

Expand Down
6 changes: 3 additions & 3 deletions sdk/keyvault/arm-keyvault/_meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"commit": "bb530add3bb77c84e4e042b7e094b15cad91442a",
"commit": "b8fa43756c72adab0cb47380d59d82f7c53034ec",
"readme": "specification/keyvault/resource-manager/readme.md",
"autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --typescript-sdks-folder=D:\\mydev\\azure-sdk-for-js ../azure-rest-api-specs/specification/keyvault/resource-manager/readme.md --use=@autorest/[email protected].8.20210810.1",
"autorest_command": "autorest --version=3.1.3 --typescript --modelerfour.lenient-model-deduplication --head-as-boolean=true --license-header=MICROSOFT_MIT_NO_VERSION --generate-test --typescript-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-js ../azure-rest-api-specs/specification/keyvault/resource-manager/readme.md --use=@autorest/[email protected].16.20211130.1",
"repository_url": "https://github.com/Azure/azure-rest-api-specs.git",
"use": "@autorest/[email protected].8.20210810.1"
"use": "@autorest/[email protected].16.20211130.1"
}
2 changes: 1 addition & 1 deletion sdk/keyvault/arm-keyvault/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "./dist-esm/index.d.ts",
"mainEntryPointFilePath": "./dist-esm/src/index.d.ts",
"docModel": { "enabled": true },
"apiReport": { "enabled": true, "reportFolder": "./review" },
"dtsRollup": {
Expand Down
45 changes: 19 additions & 26 deletions sdk/keyvault/arm-keyvault/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,20 @@
"author": "Microsoft Corporation",
"description": "A generated SDK for KeyVaultManagementClient.",
"version": "2.0.0-beta.2",
"engines": {
"node": ">=12.0.0"
},
"engines": { "node": ">=12.0.0" },
"dependencies": {
"@azure/core-lro": "^2.2.0",
"@azure/abort-controller": "^1.0.0",
"@azure/core-paging": "^1.1.1",
"@azure/core-paging": "^1.2.0",
"@azure/core-client": "^1.0.0",
"@azure/core-auth": "^1.3.0",
"@azure/core-rest-pipeline": "^1.1.0",
"tslib": "^2.2.0"
},
"keywords": [
"node",
"azure",
"typescript",
"browser",
"isomorphic"
],
"keywords": ["node", "azure", "typescript", "browser", "isomorphic"],
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist-esm/index.js",
"module": "./dist-esm/src/index.js",
"types": "./types/arm-keyvault.d.ts",
"devDependencies": {
"@microsoft/api-extractor": "^7.18.11",
Expand All @@ -36,18 +28,20 @@
"mkdirp": "^1.0.4",
"rollup": "^1.16.3",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-node-resolve": "^3.4.0",
"typescript": "~4.2.0",
"uglify-js": "^3.4.9"
"uglify-js": "^3.4.9",
"rimraf": "^3.0.0",
"@azure/identity": "^2.0.1",
"@azure-tools/test-recorder": "^1.0.0",
"mocha": "^7.1.1",
"cross-env": "^7.0.2"
},
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/keyvault/arm-keyvault",
"repository": {
"type": "git",
"url": "https://github.com/Azure/azure-sdk-for-js.git"
},
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
},
"bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" },
"files": [
"dist/**/*.js",
"dist/**/*.js.map",
Expand All @@ -64,34 +58,33 @@
"tsconfig.json",
"review/*",
"CHANGELOG.md",
"types"
"types/*"
],
"scripts": {
"build": "tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api",
"build": "npm run clean && tsc && rollup -c 2>&1 && npm run minify && mkdirp ./review && npm run extract-api",
"minify": "uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
"prepack": "npm run build",
"pack": "npm pack 2>&1",
"extract-api": "api-extractor run --local",
"lint": "echo skipped",
"audit": "echo skipped",
"clean": "echo skipped",
"clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log",
"build:node": "echo skipped",
"build:browser": "echo skipped",
"build:test": "echo skipped",
"build:samples": "echo skipped.",
"check-format": "echo skipped",
"execute:samples": "echo skipped",
"format": "echo skipped",
"test": "echo skipped",
"prebuild": "echo skipped",
"test": "npm run integration-test",
"test:node": "echo skipped",
"test:browser": "echo skipped",
"unit-test": "echo skipped",
"unit-test:node": "echo skipped",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:node": "cross-env TEST_MODE=playback npm run integration-test:node",
"unit-test:browser": "echo skipped",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"integration-test:node": "mocha -r esm --require ts-node/register --timeout 1200000 --full-trace test/*.ts --reporter ../../../common/tools/mocha-multi-reporter.js",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test": "echo skipped",
"docs": "echo skipped"
},
"sideEffects": false,
Expand Down
34 changes: 22 additions & 12 deletions sdk/keyvault/arm-keyvault/review/arm-keyvault.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ export type Key = Resource & {
readonly keyUri?: string;
readonly keyUriWithVersion?: string;
rotationPolicy?: RotationPolicy;
releasePolicy?: KeyReleasePolicy;
};

// @public
export interface KeyAttributes {
readonly created?: number;
enabled?: boolean;
expires?: number;
exportable?: boolean;
notBefore?: number;
readonly recoveryLevel?: DeletionRecoveryLevel;
readonly updated?: number;
Expand Down Expand Up @@ -197,9 +199,16 @@ export interface KeyProperties {
readonly keyUri?: string;
readonly keyUriWithVersion?: string;
kty?: JsonWebKeyType;
releasePolicy?: KeyReleasePolicy;
rotationPolicy?: RotationPolicy;
}

// @public (undocumented)
export interface KeyReleasePolicy {
contentType?: string;
data?: Uint8Array;
}

// @public
export type KeyRotationPolicyActionType = "rotate" | "notify";

Expand Down Expand Up @@ -269,9 +278,13 @@ export interface KeysListVersionsOptionalParams extends coreClient.OperationOpti
export type KeysListVersionsResponse = KeyListResult;

// @public (undocumented)
export class KeyVaultManagementClient extends KeyVaultManagementClientContext {
export class KeyVaultManagementClient extends coreClient.ServiceClient {
// (undocumented)
$host: string;
constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: KeyVaultManagementClientOptionalParams);
// (undocumented)
apiVersion: string;
// (undocumented)
keys: Keys;
// (undocumented)
managedHsms: ManagedHsms;
Expand All @@ -288,18 +301,9 @@ export class KeyVaultManagementClient extends KeyVaultManagementClientContext {
// (undocumented)
secrets: Secrets;
// (undocumented)
vaults: Vaults;
}

// @public (undocumented)
export class KeyVaultManagementClientContext extends coreClient.ServiceClient {
// (undocumented)
$host: string;
constructor(credentials: coreAuth.TokenCredential, subscriptionId: string, options?: KeyVaultManagementClientOptionalParams);
// (undocumented)
apiVersion: string;
// (undocumented)
subscriptionId: string;
// (undocumented)
vaults: Vaults;
}

// @public
Expand Down Expand Up @@ -398,6 +402,8 @@ export enum KnownJsonWebKeyOperation {
// (undocumented)
Import = "import",
// (undocumented)
Release = "release",
// (undocumented)
Sign = "sign",
// (undocumented)
UnwrapKey = "unwrapKey",
Expand Down Expand Up @@ -436,6 +442,8 @@ export enum KnownKeyPermissions {
// (undocumented)
Get = "get",
// (undocumented)
Getrotationpolicy = "getrotationpolicy",
// (undocumented)
Import = "import",
// (undocumented)
List = "list",
Expand All @@ -450,6 +458,8 @@ export enum KnownKeyPermissions {
// (undocumented)
Rotate = "rotate",
// (undocumented)
Setrotationpolicy = "setrotationpolicy",
// (undocumented)
Sign = "sign",
// (undocumented)
UnwrapKey = "unwrapKey",
Expand Down
1 change: 0 additions & 1 deletion sdk/keyvault/arm-keyvault/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
/// <reference lib="esnext.asynciterable" />
export * from "./models";
export { KeyVaultManagementClient } from "./keyVaultManagementClient";
export { KeyVaultManagementClientContext } from "./keyVaultManagementClientContext";
export * from "./operationsInterfaces";
49 changes: 46 additions & 3 deletions sdk/keyvault/arm-keyvault/src/keyVaultManagementClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/

import * as coreClient from "@azure/core-client";
import * as coreAuth from "@azure/core-auth";
import {
KeysImpl,
Expand All @@ -29,10 +30,13 @@ import {
Operations,
Secrets
} from "./operationsInterfaces";
import { KeyVaultManagementClientContext } from "./keyVaultManagementClientContext";
import { KeyVaultManagementClientOptionalParams } from "./models";

export class KeyVaultManagementClient extends KeyVaultManagementClientContext {
export class KeyVaultManagementClient extends coreClient.ServiceClient {
$host: string;
subscriptionId: string;
apiVersion: string;

/**
* Initializes a new instance of the KeyVaultManagementClient class.
* @param credentials Subscription credentials which uniquely identify client subscription.
Expand All @@ -45,7 +49,46 @@ export class KeyVaultManagementClient extends KeyVaultManagementClientContext {
subscriptionId: string,
options?: KeyVaultManagementClientOptionalParams
) {
super(credentials, subscriptionId, options);
if (credentials === undefined) {
throw new Error("'credentials' cannot be null");
}
if (subscriptionId === undefined) {
throw new Error("'subscriptionId' cannot be null");
}

// Initializing default values for options
if (!options) {
options = {};
}
const defaults: KeyVaultManagementClientOptionalParams = {
requestContentType: "application/json; charset=utf-8",
credential: credentials
};

const packageDetails = `azsdk-js-arm-keyvault/2.0.0-beta.2`;
const userAgentPrefix =
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
: `${packageDetails}`;

if (!options.credentialScopes) {
options.credentialScopes = ["https://management.azure.com/.default"];
}
const optionsWithDefaults = {
...defaults,
...options,
userAgentOptions: {
userAgentPrefix
},
baseUri: options.endpoint || "https://management.azure.com"
};
super(optionsWithDefaults);
// Parameter assignments
this.subscriptionId = subscriptionId;

// Assigning values to Constant parameters
this.$host = options.$host || "https://management.azure.com";
this.apiVersion = options.apiVersion || "2021-06-01-preview";
this.keys = new KeysImpl(this);
this.vaults = new VaultsImpl(this);
this.privateEndpointConnections = new PrivateEndpointConnectionsImpl(this);
Expand Down
Loading

0 comments on commit cfde187

Please sign in to comment.