Skip to content

Commit

Permalink
feat(keychain-azure-kv): complete request handler and endpoints
Browse files Browse the repository at this point in the history
Fixes #1010
Depends on #1349

Signed-off-by: Youngone Lee <[email protected]>
Signed-off-by: Jeffery Ushry <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
Leeyoungone authored and petermetz committed Apr 3, 2022
1 parent eccef40 commit 932df10
Show file tree
Hide file tree
Showing 10 changed files with 862 additions and 53 deletions.
5 changes: 5 additions & 0 deletions packages/cactus-plugin-keychain-azure-kv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"name": "Peter Somogyvari",
"email": "[email protected]",
"url": "https://accenture.com"
},
{
"name": "Jeffrey Ushry II",
"email": "[email protected]",
"url": "https://www.linkedin.com/in/jeffrey-ushry-ii-aa7ab8183"
}
],
"main": "dist/lib/main/typescript/index.js",
Expand Down
99 changes: 84 additions & 15 deletions packages/cactus-plugin-keychain-azure-kv/src/main/json/openapi.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
{
"openapi": "3.0.3",
"info": {
"title": "Hyperledger Cactus - Keychain API",
"description": "Contains/describes the Keychain API types/paths for Hyperledger Cactus.",
"version": "0.3.0",
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"components": {
"schemas": {
}
},
"openapi": "3.0.3",
"info": {
"title": "Hyperledger Cactus - Keychain API",
"description": "Contains/describes the Keychain API types/paths for Hyperledger Cactus.",
"version": "0.3.0",
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"components": {
"schemas": {
"GetSecretRequest": {
"type": "string",
"nullable": false
},
"GetSecretResponse": {
"type": "string",
"nullable": false
}
}
},
"paths": {
"/api/v1/plugins/@hyperledger/cactus-plugin-keychain-azure-kv/get-keychain-entry": {
"post": {
Expand Down Expand Up @@ -76,6 +84,67 @@
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-keychain-azure-kv/delete-keychain-entry": {
"post": {
"x-hyperledger-cactus": {
"http": {
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-keychain-azure-kv/delete-keychain-entry",
"verbLowerCase": "post"
}
},
"operationId": "deleteKeychainEntryV1",
"summary": "Deletes a value under a key on the keychain backend.",
"parameters": [],
"requestBody": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/requestBodies/keychain_delete_entry_request_body"
},
"responses": {
"200": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_delete_entry_200"
},
"400": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_delete_entry_400"
},
"401": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_delete_entry_401"
},
"500": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_delete_entry_500"
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-keychain-azure-kv/has-keychain-entry": {
"post": {
"x-hyperledger-cactus": {
"http": {
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-keychain-azure-kv/has-keychain-entry",
"verbLowerCase": "post"
}
},
"operationId": "hasKeychainEntryV1",
"summary": "Checks that an entry exists under a key on the keychain backend",
"parameters": [],
"requestBody": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/requestBodies/keychain_has_entry_request_body"
},
"responses": {
"200": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_has_entry_200"
},
"400": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_has_entry_400"
},
"401": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_has_entry_401"
},
"500": {
"$ref": "https://raw.githubusercontent.com/hyperledger/cactus/v0.9.0/packages/cactus-core-api/src/main/json/openapi.json#/components/responses/keychain_has_entry_500"
}
}
}
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObj
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base';

/**
*
* @export
* @interface DeleteKeychainEntryRequestV1
*/
export interface DeleteKeychainEntryRequestV1 {
/**
* The key for the entry to check the presence of on the keychain.
* @type {string}
* @memberof DeleteKeychainEntryRequestV1
*/
key: string;
}
/**
*
* @export
* @interface DeleteKeychainEntryResponseV1
*/
export interface DeleteKeychainEntryResponseV1 {
/**
* The key that was deleted from the keychain.
* @type {string}
* @memberof DeleteKeychainEntryResponseV1
*/
key: string;
}
/**
*
* @export
Expand Down Expand Up @@ -53,6 +79,44 @@ export interface GetKeychainEntryResponse {
*/
value: string;
}
/**
*
* @export
* @interface HasKeychainEntryRequestV1
*/
export interface HasKeychainEntryRequestV1 {
/**
* The key to check for presence in the keychain.
* @type {string}
* @memberof HasKeychainEntryRequestV1
*/
key: string;
}
/**
*
* @export
* @interface HasKeychainEntryResponseV1
*/
export interface HasKeychainEntryResponseV1 {
/**
* The key that was used to check the presence of the value in the entry store.
* @type {string}
* @memberof HasKeychainEntryResponseV1
*/
key: string;
/**
* Date and time encoded as JSON when the presence check was performed by the plugin backend.
* @type {string}
* @memberof HasKeychainEntryResponseV1
*/
checkedAt: string;
/**
* The boolean true or false indicating the presence or absence of an entry under \'key\'.
* @type {boolean}
* @memberof HasKeychainEntryResponseV1
*/
isPresent: boolean;
}
/**
*
* @export
Expand Down Expand Up @@ -92,6 +156,42 @@ export interface SetKeychainEntryResponse {
*/
export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @summary Deletes a value under a key on the keychain backend.
* @param {DeleteKeychainEntryRequestV1} deleteKeychainEntryRequestV1 Request body to delete a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteKeychainEntryV1: async (deleteKeychainEntryRequestV1: DeleteKeychainEntryRequestV1, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'deleteKeychainEntryRequestV1' is not null or undefined
assertParamExists('deleteKeychainEntryV1', 'deleteKeychainEntryRequestV1', deleteKeychainEntryRequestV1)
const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-keychain-azure-kv/delete-keychain-entry`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(deleteKeychainEntryRequestV1, localVarRequestOptions, configuration)

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Retrieves the contents of a keychain entry from the backend.
Expand Down Expand Up @@ -128,6 +228,42 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
options: localVarRequestOptions,
};
},
/**
*
* @summary Checks that an entry exists under a key on the keychain backend
* @param {HasKeychainEntryRequestV1} hasKeychainEntryRequestV1 Request body for checking a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
hasKeychainEntryV1: async (hasKeychainEntryRequestV1: HasKeychainEntryRequestV1, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'hasKeychainEntryRequestV1' is not null or undefined
assertParamExists('hasKeychainEntryV1', 'hasKeychainEntryRequestV1', hasKeychainEntryRequestV1)
const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-keychain-azure-kv/has-keychain-entry`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(hasKeychainEntryRequestV1, localVarRequestOptions, configuration)

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Sets a value under a key on the keychain backend.
Expand Down Expand Up @@ -174,6 +310,17 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
export const DefaultApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration)
return {
/**
*
* @summary Deletes a value under a key on the keychain backend.
* @param {DeleteKeychainEntryRequestV1} deleteKeychainEntryRequestV1 Request body to delete a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async deleteKeychainEntryV1(deleteKeychainEntryRequestV1: DeleteKeychainEntryRequestV1, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<DeleteKeychainEntryResponseV1>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.deleteKeychainEntryV1(deleteKeychainEntryRequestV1, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Retrieves the contents of a keychain entry from the backend.
Expand All @@ -185,6 +332,17 @@ export const DefaultApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.getKeychainEntryV1(getKeychainEntryRequest, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Checks that an entry exists under a key on the keychain backend
* @param {HasKeychainEntryRequestV1} hasKeychainEntryRequestV1 Request body for checking a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async hasKeychainEntryV1(hasKeychainEntryRequestV1: HasKeychainEntryRequestV1, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<HasKeychainEntryResponseV1>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.hasKeychainEntryV1(hasKeychainEntryRequestV1, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Sets a value under a key on the keychain backend.
Expand All @@ -206,6 +364,16 @@ export const DefaultApiFp = function(configuration?: Configuration) {
export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = DefaultApiFp(configuration)
return {
/**
*
* @summary Deletes a value under a key on the keychain backend.
* @param {DeleteKeychainEntryRequestV1} deleteKeychainEntryRequestV1 Request body to delete a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deleteKeychainEntryV1(deleteKeychainEntryRequestV1: DeleteKeychainEntryRequestV1, options?: any): AxiosPromise<DeleteKeychainEntryResponseV1> {
return localVarFp.deleteKeychainEntryV1(deleteKeychainEntryRequestV1, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Retrieves the contents of a keychain entry from the backend.
Expand All @@ -216,6 +384,16 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
getKeychainEntryV1(getKeychainEntryRequest: GetKeychainEntryRequest, options?: any): AxiosPromise<GetKeychainEntryResponse> {
return localVarFp.getKeychainEntryV1(getKeychainEntryRequest, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Checks that an entry exists under a key on the keychain backend
* @param {HasKeychainEntryRequestV1} hasKeychainEntryRequestV1 Request body for checking a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
hasKeychainEntryV1(hasKeychainEntryRequestV1: HasKeychainEntryRequestV1, options?: any): AxiosPromise<HasKeychainEntryResponseV1> {
return localVarFp.hasKeychainEntryV1(hasKeychainEntryRequestV1, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Sets a value under a key on the keychain backend.
Expand All @@ -236,6 +414,18 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
* @extends {BaseAPI}
*/
export class DefaultApi extends BaseAPI {
/**
*
* @summary Deletes a value under a key on the keychain backend.
* @param {DeleteKeychainEntryRequestV1} deleteKeychainEntryRequestV1 Request body to delete a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public deleteKeychainEntryV1(deleteKeychainEntryRequestV1: DeleteKeychainEntryRequestV1, options?: any) {
return DefaultApiFp(this.configuration).deleteKeychainEntryV1(deleteKeychainEntryRequestV1, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Retrieves the contents of a keychain entry from the backend.
Expand All @@ -248,6 +438,18 @@ export class DefaultApi extends BaseAPI {
return DefaultApiFp(this.configuration).getKeychainEntryV1(getKeychainEntryRequest, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Checks that an entry exists under a key on the keychain backend
* @param {HasKeychainEntryRequestV1} hasKeychainEntryRequestV1 Request body for checking a keychain entry via its key
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public hasKeychainEntryV1(hasKeychainEntryRequestV1: HasKeychainEntryRequestV1, options?: any) {
return DefaultApiFp(this.configuration).hasKeychainEntryV1(hasKeychainEntryRequestV1, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Sets a value under a key on the keychain backend.
Expand Down
Loading

0 comments on commit 932df10

Please sign in to comment.