From bf852ebe0c33124aa210502ce8b1c8df03709534 Mon Sep 17 00:00:00 2001 From: Msarawan Date: Fri, 25 Oct 2024 16:08:33 +0530 Subject: [PATCH] [NO-ISSUE] Update Openapi.yml to 0.1.1 --- api-server/openapi.yml | 210 +++++++++++++++++- src/openapi/jolokia/queries/index.ts | 126 +++++++++++ src/openapi/jolokia/requests/core/OpenAPI.ts | 2 +- src/openapi/jolokia/requests/index.ts | 1 + .../requests/models/ClusterConnection.ts | 10 + .../requests/services/JolokiaService.ts | 135 +++++++++++ 6 files changed, 481 insertions(+), 3 deletions(-) create mode 100644 src/openapi/jolokia/requests/models/ClusterConnection.ts diff --git a/api-server/openapi.yml b/api-server/openapi.yml index f14bb425..9e4807df 100644 --- a/api-server/openapi.yml +++ b/api-server/openapi.yml @@ -6,9 +6,9 @@ info: license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0 - version: 1.0.0-alpha + version: 0.1.1 description: | - This document contains a list of currently avaliable apis that + This document contains a list of currently available apis that can be used by the **activemq-artemis-self-provisioning plugin** to get access to the [management api](https://github.com/apache/activemq-artemis/blob/main/docs/user-manual/management.adoc#the-management-api) of a broker instance via its [jolokia](https://jolokia.org/) endpoint. @@ -483,6 +483,118 @@ paths: schema: type: object $ref: '#/components/schemas/FailureResponse' + /readClusterConnectionAttributes: + get: + summary: read cluster connection attributes + description: > + **Read values of cluster connection attributes** + The return value is a json array that contains + values of requested attributes of the cluster connection's mbean. + + **Note**: to read multiple attributes, set it to **attrs** parameter + separated by commas, e.g. `NodeID, Topology`. + tags: + - jolokia + operationId: readClusterConnectionAttributes + parameters: + - in: header + name: jolokia-session-id + schema: + type: string + required: true + - name: name + description: the cluster connection name + schema: + type: string + required: true + in: query + - name: attrs + description: attribute names separated by commas. If not speified read all attributes. + required: false + in: query + schema: + type: array + items: + type: string + style: form + explode: false + responses: + 200: + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ComponentAttribute' + 401: + description: Invalid credentials + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' + 500: + description: Internal server error + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' + /execClusterConnectionOperation: + post: + summary: execute a cluster connection operation + description: > + **Invoke an operation of the cluster connection mbean** + + It receives a POST request where the body + should have the operation signature and its args. + The return value is a one element json array that contains + return values of invoked operation along with the request info. + tags: + - jolokia + operationId: execClusterConnectionOperation + parameters: + - in: header + name: jolokia-session-id + schema: + type: string + required: true + - in: query + name: name + schema: + type: string + required: true + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OperationRef' + responses: + 200: + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ExecResult' + 401: + description: Invalid credentials + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' + 500: + description: Internal server error + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' + /checkCredentials: get: summary: Check the validity of the credentials @@ -875,6 +987,90 @@ paths: schema: type: object $ref: '#/components/schemas/FailureResponse' + /clusterConnections: + get: + summary: list cluster connections + description: > + **Get all cluster connections in a broker** + + It retrieves and returns a list of all cluster connection mbeans + tags: + - jolokia + operationId: getClusterConnections + parameters: + - in: header + name: jolokia-session-id + schema: + type: string + required: true + responses: + 200: + description: Success + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/ClusterConnection' + 401: + description: Invalid credentials + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' + 500: + description: Internal server error + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' + /clusterConnectionDetails: + get: + summary: retrieve cluster connection details + description: > + **Get details of a connection cluster** + The return value is a json object that contains + description of all the operations and attributes of a `cluster connection` mbean. + + It is defined in [ClusterConnectionControl.java](https://github.com/apache/activemq-artemis/blob/2.33.0/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ClusterConnectionControl.java) + tags: + - jolokia + operationId: getClusterConnectionDetails + parameters: + - in: header + name: jolokia-session-id + schema: + type: string + required: true + - name: name + required: true + in: query + schema: + type: string + description: the cluster connection name + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ComponentDetails' + 401: + description: Invalid credentials + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' + 500: + description: Internal server error + content: + application/json: + schema: + type: object + $ref: '#/components/schemas/FailureResponse' /api-info: get: summary: the api info @@ -1035,6 +1231,16 @@ components: type: string broker: $ref: '#/components/schemas/Broker' + ClusterConnection: + type: object + required: + - name + - broker + properties: + name: + type: string + broker: + $ref: '#/components/schemas/Broker' Queue: type: object required: diff --git a/src/openapi/jolokia/queries/index.ts b/src/openapi/jolokia/queries/index.ts index 124de977..2a446cec 100644 --- a/src/openapi/jolokia/queries/index.ts +++ b/src/openapi/jolokia/queries/index.ts @@ -226,6 +226,72 @@ export const useJolokiaServiceReadAcceptorAttributes = < () => JolokiaService.readAcceptorAttributes(jolokiaSessionId, name, attrs), options, ); +export const useJolokiaServiceReadClusterConnectionAttributesKey = + 'JolokiaServiceReadClusterConnectionAttributes'; +export const useJolokiaServiceReadClusterConnectionAttributes = < + TQueryKey extends Array = unknown[], +>( + { + jolokiaSessionId, + name, + attrs, + }: { + jolokiaSessionId: string; + name: string; + attrs?: Array; + }, + queryKey?: TQueryKey, + options?: Omit< + UseQueryOptions< + Awaited< + ReturnType + >, + unknown, + Awaited< + ReturnType + >, + unknown[] + >, + 'queryKey' | 'queryFn' | 'initialData' + >, +) => + useQuery( + [ + useJolokiaServiceReadClusterConnectionAttributesKey, + ...(queryKey ?? [{ jolokiaSessionId, name, attrs }]), + ], + () => + JolokiaService.readClusterConnectionAttributes( + jolokiaSessionId, + name, + attrs, + ), + options, + ); +export const useJolokiaServiceExecClusterConnectionOperation = ( + options?: Omit< + UseMutationOptions< + Awaited>, + unknown, + { + jolokiaSessionId: string; + name: string; + requestBody: OperationRef; + }, + unknown + >, + 'mutationFn' + >, +) => + useMutation( + ({ jolokiaSessionId, name, requestBody }) => + JolokiaService.execClusterConnectionOperation( + jolokiaSessionId, + name, + requestBody, + ), + options, + ); export const useJolokiaServiceCheckCredentialsKey = 'JolokiaServiceCheckCredentials'; export const useJolokiaServiceCheckCredentials = < @@ -486,6 +552,66 @@ export const useJolokiaServiceGetAcceptorDetails = < () => JolokiaService.getAcceptorDetails(jolokiaSessionId, name), options, ); +export const useJolokiaServiceGetClusterConnectionsKey = + 'JolokiaServiceGetClusterConnections'; +export const useJolokiaServiceGetClusterConnections = < + TQueryKey extends Array = unknown[], +>( + { + jolokiaSessionId, + }: { + jolokiaSessionId: string; + }, + queryKey?: TQueryKey, + options?: Omit< + UseQueryOptions< + Awaited>, + unknown, + Awaited>, + unknown[] + >, + 'queryKey' | 'queryFn' | 'initialData' + >, +) => + useQuery( + [ + useJolokiaServiceGetClusterConnectionsKey, + ...(queryKey ?? [{ jolokiaSessionId }]), + ], + () => JolokiaService.getClusterConnections(jolokiaSessionId), + options, + ); +export const useJolokiaServiceGetClusterConnectionDetailsKey = + 'JolokiaServiceGetClusterConnectionDetails'; +export const useJolokiaServiceGetClusterConnectionDetails = < + TQueryKey extends Array = unknown[], +>( + { + jolokiaSessionId, + name, + }: { + jolokiaSessionId: string; + name: string; + }, + queryKey?: TQueryKey, + options?: Omit< + UseQueryOptions< + Awaited>, + unknown, + Awaited>, + unknown[] + >, + 'queryKey' | 'queryFn' | 'initialData' + >, +) => + useQuery( + [ + useJolokiaServiceGetClusterConnectionDetailsKey, + ...(queryKey ?? [{ jolokiaSessionId, name }]), + ], + () => JolokiaService.getClusterConnectionDetails(jolokiaSessionId, name), + options, + ); export const useDevelopmentServiceApiInfoKey = 'DevelopmentServiceApiInfo'; export const useDevelopmentServiceApiInfo = < TQueryKey extends Array = unknown[], diff --git a/src/openapi/jolokia/requests/core/OpenAPI.ts b/src/openapi/jolokia/requests/core/OpenAPI.ts index 2ba3929a..d80bbb26 100644 --- a/src/openapi/jolokia/requests/core/OpenAPI.ts +++ b/src/openapi/jolokia/requests/core/OpenAPI.ts @@ -20,7 +20,7 @@ export type OpenAPIConfig = { export const OpenAPI: OpenAPIConfig = { BASE: '/api/v1', - VERSION: '1.0.0-alpha', + VERSION: '0.1.1', WITH_CREDENTIALS: false, CREDENTIALS: 'include', TOKEN: undefined, diff --git a/src/openapi/jolokia/requests/index.ts b/src/openapi/jolokia/requests/index.ts index 44ff555a..ed8bcee0 100644 --- a/src/openapi/jolokia/requests/index.ts +++ b/src/openapi/jolokia/requests/index.ts @@ -12,6 +12,7 @@ export { ApiResponse } from './models/ApiResponse'; export type { Argument } from './models/Argument'; export type { Attr } from './models/Attr'; export type { Broker } from './models/Broker'; +export type { ClusterConnection } from './models/ClusterConnection'; export type { ComponentAttribute } from './models/ComponentAttribute'; export type { ComponentDetails } from './models/ComponentDetails'; export { DummyResponse } from './models/DummyResponse'; diff --git a/src/openapi/jolokia/requests/models/ClusterConnection.ts b/src/openapi/jolokia/requests/models/ClusterConnection.ts new file mode 100644 index 00000000..7ce8863e --- /dev/null +++ b/src/openapi/jolokia/requests/models/ClusterConnection.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Broker } from './Broker'; + +export type ClusterConnection = { + name: string; + broker: Broker; +}; diff --git a/src/openapi/jolokia/requests/services/JolokiaService.ts b/src/openapi/jolokia/requests/services/JolokiaService.ts index b31ba842..3531dd16 100644 --- a/src/openapi/jolokia/requests/services/JolokiaService.ts +++ b/src/openapi/jolokia/requests/services/JolokiaService.ts @@ -4,6 +4,7 @@ import type { Acceptor } from '../models/Acceptor'; import type { Address } from '../models/Address'; import type { Broker } from '../models/Broker'; +import type { ClusterConnection } from '../models/ClusterConnection'; import type { ComponentAttribute } from '../models/ComponentAttribute'; import type { ComponentDetails } from '../models/ComponentDetails'; import type { DummyResponse } from '../models/DummyResponse'; @@ -220,6 +221,81 @@ export class JolokiaService { }); } + /** + * read cluster connection attributes + * **Read values of cluster connection attributes** + * The return value is a json array that contains + * values of requested attributes of the cluster connection's mbean. + * + * **Note**: to read multiple attributes, set it to **attrs** parameter + * separated by commas, e.g. `NodeID, Topology`. + * + * @param jolokiaSessionId + * @param name the cluster connection name + * @param attrs attribute names separated by commas. If not speified read all attributes. + * @returns ComponentAttribute Success + * @throws ApiError + */ + public static readClusterConnectionAttributes( + jolokiaSessionId: string, + name: string, + attrs?: Array, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/readClusterConnectionAttributes', + headers: { + 'jolokia-session-id': jolokiaSessionId, + }, + query: { + name: name, + attrs: attrs, + }, + errors: { + 401: `Invalid credentials`, + 500: `Internal server error`, + }, + }); + } + + /** + * execute a cluster connection operation + * **Invoke an operation of the cluster connection mbean** + * + * It receives a POST request where the body + * should have the operation signature and its args. + * The return value is a one element json array that contains + * return values of invoked operation along with the request info. + * + * @param jolokiaSessionId + * @param name + * @param requestBody + * @returns ExecResult Success + * @throws ApiError + */ + public static execClusterConnectionOperation( + jolokiaSessionId: string, + name: string, + requestBody: OperationRef, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'POST', + url: '/execClusterConnectionOperation', + headers: { + 'jolokia-session-id': jolokiaSessionId, + }, + query: { + name: name, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 401: `Invalid credentials`, + 500: `Internal server error`, + }, + }); + } + /** * Check the validity of the credentials * @param jolokiaSessionId @@ -489,4 +565,63 @@ export class JolokiaService { }, }); } + + /** + * list cluster connections + * **Get all cluster connections in a broker** + * + * It retrieves and returns a list of all cluster connection mbeans + * + * @param jolokiaSessionId + * @returns ClusterConnection Success + * @throws ApiError + */ + public static getClusterConnections( + jolokiaSessionId: string, + ): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/clusterConnections', + headers: { + 'jolokia-session-id': jolokiaSessionId, + }, + errors: { + 401: `Invalid credentials`, + 500: `Internal server error`, + }, + }); + } + + /** + * retrieve cluster connection details + * **Get details of a connection cluster** + * The return value is a json object that contains + * description of all the operations and attributes of a `cluster connection` mbean. + * + * It is defined in [ClusterConnectionControl.java](https://github.com/apache/activemq-artemis/blob/2.33.0/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/management/ClusterConnectionControl.java) + * + * @param jolokiaSessionId + * @param name + * @returns ComponentDetails Success + * @throws ApiError + */ + public static getClusterConnectionDetails( + jolokiaSessionId: string, + name: string, + ): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/clusterConnectionDetails', + headers: { + 'jolokia-session-id': jolokiaSessionId, + }, + query: { + name: name, + }, + errors: { + 401: `Invalid credentials`, + 500: `Internal server error`, + }, + }); + } }