Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Key Vault Admin] No LROs on the generated code for now #11008

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 21 additions & 134 deletions sdk/keyvault/keyvault-admin/src/generated/keyVaultClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import * as coreHttp from "@azure/core-http";
import { LROPoller, shouldDeserializeLRO } from "./lro";
import * as operations from "./operations";
import * as Parameters from "./models/parameters";
import * as Models from "./models";
Expand Down Expand Up @@ -36,55 +35,22 @@ class KeyVaultClient extends KeyVaultClientContext {
this.roleAssignments = new operations.RoleAssignments(this);
}

private getOperationOptions<TOptions extends coreHttp.OperationOptions>(
options: TOptions | undefined,
finalStateVia?: string
): coreHttp.RequestOptionsBase {
const operationOptions: coreHttp.OperationOptions = options || {};
operationOptions.requestOptions = {
...operationOptions.requestOptions,
shouldDeserialize: shouldDeserializeLRO(finalStateVia)
};
return coreHttp.operationOptionsToRequestOptionsBase(operationOptions);
}

/**
* Creates a full backup using a user-provided SAS token to an Azure blob storage container.
* @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
* @param options The options parameters.
*/
async fullBackup(
fullBackup(
vaultBaseUrl: string,
options?: KeyVaultClientFullBackupOptionalParams
): Promise<LROPoller<KeyVaultClientFullBackupResponse>> {
const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions(
options,
"azure-async-operation"
): Promise<KeyVaultClientFullBackupResponse> {
const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(
options || {}
);

const args: coreHttp.OperationArguments = {
vaultBaseUrl,
options: operationOptions
};
const sendOperation = (
args: coreHttp.OperationArguments,
spec: coreHttp.OperationSpec
) =>
this.sendOperationRequest(args, spec) as Promise<
KeyVaultClientFullBackupResponse
>;
const initialOperationResult = await sendOperation(
args,
return this.sendOperationRequest(
{ vaultBaseUrl, options: operationOptions },
fullBackupOperationSpec
);

return new LROPoller({
initialOperationArguments: args,
initialOperationSpec: fullBackupOperationSpec,
initialOperationResult,
sendOperation,
finalStateVia: "azure-async-operation"
});
) as Promise<KeyVaultClientFullBackupResponse>;
}

/**
Expand Down Expand Up @@ -113,38 +79,17 @@ class KeyVaultClient extends KeyVaultClientContext {
* @param vaultBaseUrl The vault name, for example https://myvault.vault.azure.net.
* @param options The options parameters.
*/
async fullRestoreOperation(
fullRestoreOperation(
vaultBaseUrl: string,
options?: KeyVaultClientFullRestoreOperationOptionalParams
): Promise<LROPoller<KeyVaultClientFullRestoreOperationResponse>> {
const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions(
options,
"azure-async-operation"
): Promise<KeyVaultClientFullRestoreOperationResponse> {
const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(
options || {}
);

const args: coreHttp.OperationArguments = {
vaultBaseUrl,
options: operationOptions
};
const sendOperation = (
args: coreHttp.OperationArguments,
spec: coreHttp.OperationSpec
) =>
this.sendOperationRequest(args, spec) as Promise<
KeyVaultClientFullRestoreOperationResponse
>;
const initialOperationResult = await sendOperation(
args,
return this.sendOperationRequest(
{ vaultBaseUrl, options: operationOptions },
fullRestoreOperationOperationSpec
);

return new LROPoller({
initialOperationArguments: args,
initialOperationSpec: fullRestoreOperationOperationSpec,
initialOperationResult,
sendOperation,
finalStateVia: "azure-async-operation"
});
) as Promise<KeyVaultClientFullRestoreOperationResponse>;
}

/**
Expand Down Expand Up @@ -174,40 +119,18 @@ class KeyVaultClient extends KeyVaultClientContext {
* @param keyName The name of the key to be restored from the user supplied backup
* @param options The options parameters.
*/
async selectiveKeyRestoreOperation(
selectiveKeyRestoreOperation(
vaultBaseUrl: string,
keyName: string,
options?: KeyVaultClientSelectiveKeyRestoreOperationOptionalParams
): Promise<LROPoller<KeyVaultClientSelectiveKeyRestoreOperationResponse>> {
const operationOptions: coreHttp.RequestOptionsBase = this.getOperationOptions(
options,
"azure-async-operation"
): Promise<KeyVaultClientSelectiveKeyRestoreOperationResponse> {
const operationOptions: coreHttp.RequestOptionsBase = coreHttp.operationOptionsToRequestOptionsBase(
options || {}
);

const args: coreHttp.OperationArguments = {
vaultBaseUrl,
keyName,
options: operationOptions
};
const sendOperation = (
args: coreHttp.OperationArguments,
spec: coreHttp.OperationSpec
) =>
this.sendOperationRequest(args, spec) as Promise<
KeyVaultClientSelectiveKeyRestoreOperationResponse
>;
const initialOperationResult = await sendOperation(
args,
return this.sendOperationRequest(
{ vaultBaseUrl, keyName, options: operationOptions },
selectiveKeyRestoreOperationOperationSpec
);

return new LROPoller({
initialOperationArguments: args,
initialOperationSpec: selectiveKeyRestoreOperationOperationSpec,
initialOperationResult,
sendOperation,
finalStateVia: "azure-async-operation"
});
) as Promise<KeyVaultClientSelectiveKeyRestoreOperationResponse>;
}

roleDefinitions: operations.RoleDefinitions;
Expand All @@ -221,22 +144,10 @@ const fullBackupOperationSpec: coreHttp.OperationSpec = {
path: "/backup",
httpMethod: "POST",
responses: {
200: {
bodyMapper: Mappers.FullBackupOperation,
headersMapper: Mappers.KeyVaultClientFullBackupHeaders
},
201: {
bodyMapper: Mappers.FullBackupOperation,
headersMapper: Mappers.KeyVaultClientFullBackupHeaders
},
202: {
bodyMapper: Mappers.FullBackupOperation,
headersMapper: Mappers.KeyVaultClientFullBackupHeaders
},
204: {
bodyMapper: Mappers.FullBackupOperation,
headersMapper: Mappers.KeyVaultClientFullBackupHeaders
},
default: {
bodyMapper: Mappers.KeyVaultError
}
Expand Down Expand Up @@ -267,22 +178,10 @@ const fullRestoreOperationOperationSpec: coreHttp.OperationSpec = {
path: "/restore",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.RestoreOperation,
headersMapper: Mappers.KeyVaultClientFullRestoreOperationHeaders
},
201: {
bodyMapper: Mappers.RestoreOperation,
headersMapper: Mappers.KeyVaultClientFullRestoreOperationHeaders
},
202: {
bodyMapper: Mappers.RestoreOperation,
headersMapper: Mappers.KeyVaultClientFullRestoreOperationHeaders
},
204: {
bodyMapper: Mappers.RestoreOperation,
headersMapper: Mappers.KeyVaultClientFullRestoreOperationHeaders
},
default: {
bodyMapper: Mappers.KeyVaultError
}
Expand Down Expand Up @@ -313,22 +212,10 @@ const selectiveKeyRestoreOperationOperationSpec: coreHttp.OperationSpec = {
path: "/keys/{keyName}/restore",
httpMethod: "PUT",
responses: {
200: {
bodyMapper: Mappers.SelectiveKeyRestoreOperation,
headersMapper: Mappers.KeyVaultClientSelectiveKeyRestoreOperationHeaders
},
201: {
bodyMapper: Mappers.SelectiveKeyRestoreOperation,
headersMapper: Mappers.KeyVaultClientSelectiveKeyRestoreOperationHeaders
},
202: {
bodyMapper: Mappers.SelectiveKeyRestoreOperation,
headersMapper: Mappers.KeyVaultClientSelectiveKeyRestoreOperationHeaders
},
204: {
bodyMapper: Mappers.SelectiveKeyRestoreOperation,
headersMapper: Mappers.KeyVaultClientSelectiveKeyRestoreOperationHeaders
},
default: {
bodyMapper: Mappers.KeyVaultError
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import * as coreHttp from "@azure/core-http";
import { KeyVaultClientOptionalParams } from "./models";
import { lroPolicy } from "./lro";

const packageName = "@azure/keyvault-admin";
const packageVersion = "1.0.0";
Expand All @@ -31,14 +30,6 @@ export class KeyVaultClientContext extends coreHttp.ServiceClient {
options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
}

const defaultPipelines = coreHttp.createPipelineFromOptions(options)
.requestPolicyFactories as coreHttp.RequestPolicyFactory[];

options = {
...options,
requestPolicyFactories: [lroPolicy(), ...defaultPipelines]
};

super(undefined, options);

this.requestContentType = "application/json; charset=utf-8";
Expand Down
15 changes: 15 additions & 0 deletions sdk/keyvault/keyvault-admin/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,18 @@ input-file:
output-folder: ../
source-code-folder-path: ./src/generated
```

### Hide LROs
``` yaml
directive:
- from: swagger-document
where: $["paths"]
transform: >
for (var path in $) {
for (var op of Object.values($[path])) {
if (op["x-ms-long-running-operation"]) {
delete op["x-ms-long-running-operation"];
}
}
}
```