@redhat-cloud-services/notifications-client 0.0.40 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/README.md +8 -8
  2. package/dist/EventResourceV1GetEvents/index.d.ts +111 -0
  3. package/dist/EventResourceV1GetEvents/index.js +143 -0
  4. package/dist/NotificationResourceV1AppendBehaviorGroupToEventType/index.d.ts +26 -0
  5. package/dist/NotificationResourceV1AppendBehaviorGroupToEventType/index.js +93 -0
  6. package/dist/NotificationResourceV1CreateBehaviorGroup/index.d.ts +21 -0
  7. package/dist/NotificationResourceV1CreateBehaviorGroup/index.js +93 -0
  8. package/dist/NotificationResourceV1DeleteBehaviorGroup/index.d.ts +20 -0
  9. package/dist/NotificationResourceV1DeleteBehaviorGroup/index.js +92 -0
  10. package/dist/NotificationResourceV1DeleteBehaviorGroupFromEventType/index.d.ts +26 -0
  11. package/dist/NotificationResourceV1DeleteBehaviorGroupFromEventType/index.js +93 -0
  12. package/dist/NotificationResourceV1FindBehaviorGroupsByBundleId/index.d.ts +20 -0
  13. package/dist/NotificationResourceV1FindBehaviorGroupsByBundleId/index.js +92 -0
  14. package/dist/NotificationResourceV1GetApplicationByNameAndBundleName/index.d.ts +26 -0
  15. package/dist/NotificationResourceV1GetApplicationByNameAndBundleName/index.js +93 -0
  16. package/dist/NotificationResourceV1GetApplicationsFacets/index.d.ts +20 -0
  17. package/dist/NotificationResourceV1GetApplicationsFacets/index.js +94 -0
  18. package/dist/NotificationResourceV1GetBehaviorGroupsAffectedByRemovalOfEndpoint/index.d.ts +20 -0
  19. package/dist/NotificationResourceV1GetBehaviorGroupsAffectedByRemovalOfEndpoint/index.js +92 -0
  20. package/dist/NotificationResourceV1GetBundleByName/index.d.ts +20 -0
  21. package/dist/NotificationResourceV1GetBundleByName/index.js +92 -0
  22. package/dist/NotificationResourceV1GetBundleFacets/index.d.ts +20 -0
  23. package/dist/NotificationResourceV1GetBundleFacets/index.js +94 -0
  24. package/dist/NotificationResourceV1GetEventTypes/index.d.ts +62 -0
  25. package/dist/NotificationResourceV1GetEventTypes/index.js +115 -0
  26. package/dist/NotificationResourceV1GetEventTypesAffectedByRemovalOfBehaviorGroup/index.d.ts +20 -0
  27. package/dist/NotificationResourceV1GetEventTypesAffectedByRemovalOfBehaviorGroup/index.js +92 -0
  28. package/dist/NotificationResourceV1GetEventTypesByNameAndBundleAndApplicationName/index.d.ts +32 -0
  29. package/dist/NotificationResourceV1GetEventTypesByNameAndBundleAndApplicationName/index.js +94 -0
  30. package/dist/NotificationResourceV1GetLinkedBehaviorGroups/index.d.ts +50 -0
  31. package/dist/NotificationResourceV1GetLinkedBehaviorGroups/index.js +116 -0
  32. package/dist/NotificationResourceV1UpdateBehaviorGroup/index.d.ts +27 -0
  33. package/dist/NotificationResourceV1UpdateBehaviorGroup/index.js +94 -0
  34. package/dist/NotificationResourceV1UpdateBehaviorGroupActions/index.d.ts +26 -0
  35. package/dist/NotificationResourceV1UpdateBehaviorGroupActions/index.js +94 -0
  36. package/dist/NotificationResourceV1UpdateEventTypeBehaviors/index.d.ts +26 -0
  37. package/dist/NotificationResourceV1UpdateEventTypeBehaviors/index.js +94 -0
  38. package/dist/OrgConfigResourceV1GetDailyDigestTimePreference/index.d.ts +13 -0
  39. package/dist/OrgConfigResourceV1GetDailyDigestTimePreference/index.js +90 -0
  40. package/dist/OrgConfigResourceV1SaveDailyDigestTimePreference/index.d.ts +20 -0
  41. package/dist/OrgConfigResourceV1SaveDailyDigestTimePreference/index.js +93 -0
  42. package/dist/UserConfigResourceV1GetPreferences/index.d.ts +25 -0
  43. package/dist/UserConfigResourceV1GetPreferences/index.js +92 -0
  44. package/dist/UserConfigResourceV1GetSettingsSchema/index.d.ts +19 -0
  45. package/dist/UserConfigResourceV1GetSettingsSchema/index.js +93 -0
  46. package/dist/UserConfigResourceV1SaveSettings/index.d.ts +20 -0
  47. package/dist/UserConfigResourceV1SaveSettings/index.js +92 -0
  48. package/dist/api.d.ts +2536 -759
  49. package/dist/api.js +2833 -778
  50. package/dist/base.d.ts +54 -0
  51. package/dist/base.js +80 -0
  52. package/dist/common.d.ts +65 -0
  53. package/dist/common.js +252 -0
  54. package/dist/configuration.d.ts +24 -15
  55. package/dist/configuration.js +19 -12
  56. package/dist/index.d.ts +27 -13
  57. package/dist/index.js +89 -17
  58. package/dist/types/index.d.ts +1657 -0
  59. package/dist/types/index.js +90 -0
  60. package/dist/utils/base.d.ts +84 -0
  61. package/dist/utils/base.js +251 -0
  62. package/dist/utils/common.d.ts +54 -0
  63. package/dist/utils/common.js +241 -0
  64. package/dist/utils/configuration.d.ts +72 -0
  65. package/dist/utils/configuration.js +33 -0
  66. package/dist/utils/index.d.ts +3 -0
  67. package/dist/utils/index.js +19 -0
  68. package/doc/.nojekyll +1 -0
  69. package/doc/README.md +11 -420
  70. package/doc/classes/BaseAPI.md +125 -0
  71. package/doc/classes/Configuration.md +194 -0
  72. package/doc/classes/RequiredError.md +179 -0
  73. package/doc/enums/EmailSubscriptionType.md +21 -0
  74. package/doc/enums/EndpointStatus.md +76 -0
  75. package/doc/enums/EndpointType.md +65 -0
  76. package/doc/enums/Environment.md +54 -0
  77. package/doc/enums/EventLogEntryActionStatus.md +65 -0
  78. package/doc/enums/HttpType.md +43 -0
  79. package/doc/enums/NotificationStatus.md +65 -0
  80. package/doc/enums/Status.md +32 -0
  81. package/doc/interfaces/AddAccessRequest.md +44 -0
  82. package/doc/interfaces/AddApplicationRequest.md +74 -0
  83. package/doc/interfaces/AggregationEmailTemplate.md +164 -0
  84. package/doc/interfaces/ApiConfig.md +30 -0
  85. package/doc/interfaces/Application.md +104 -0
  86. package/doc/interfaces/Application1.md +44 -0
  87. package/doc/interfaces/ApplicationSettingsValue.md +33 -0
  88. package/doc/interfaces/ApplicationSettingsValue1.md +48 -0
  89. package/doc/interfaces/BasicAuthentication.md +44 -0
  90. package/doc/interfaces/BehaviorGroup.md +149 -0
  91. package/doc/interfaces/BehaviorGroupAction.md +59 -0
  92. package/doc/interfaces/BehaviorGroupActionId.md +44 -0
  93. package/doc/interfaces/Bundle.md +89 -0
  94. package/doc/interfaces/BundleSettingsValue.md +33 -0
  95. package/doc/interfaces/BundleSettingsValue1.md +33 -0
  96. package/doc/interfaces/CamelProperties.md +93 -0
  97. package/doc/interfaces/ConfigurationParameters.md +89 -0
  98. package/doc/interfaces/CreateBehaviorGroupRequest.md +104 -0
  99. package/doc/interfaces/CreateBehaviorGroupResponse.md +104 -0
  100. package/doc/interfaces/CurrentStatus.md +59 -0
  101. package/doc/interfaces/DuplicateNameMigrationReport.md +44 -0
  102. package/doc/interfaces/Endpoint.md +179 -0
  103. package/doc/interfaces/EndpointPage.md +63 -0
  104. package/doc/interfaces/EndpointTestRequest.md +29 -0
  105. package/doc/interfaces/EventLogEntry.md +119 -0
  106. package/doc/interfaces/EventLogEntryAction.md +125 -0
  107. package/doc/interfaces/EventType.md +119 -0
  108. package/doc/interfaces/EventTypeBehavior.md +59 -0
  109. package/doc/interfaces/EventTypeBehaviorId.md +44 -0
  110. package/doc/interfaces/EventTypeSettingsValue.md +48 -0
  111. package/doc/interfaces/Facet.md +74 -0
  112. package/doc/interfaces/InstantEmailTemplate.md +149 -0
  113. package/doc/interfaces/InternalApplicationUserPermission.md +59 -0
  114. package/doc/interfaces/InternalRoleAccess.md +59 -0
  115. package/doc/interfaces/InternalUserPermissions.md +59 -0
  116. package/doc/interfaces/MessageValidationResponse.md +33 -0
  117. package/doc/interfaces/Meta.md +29 -0
  118. package/doc/interfaces/NotificationHistory.md +155 -0
  119. package/doc/interfaces/PageBehaviorGroup.md +63 -0
  120. package/doc/interfaces/PageEventLogEntry.md +63 -0
  121. package/doc/interfaces/PageEventType.md +63 -0
  122. package/doc/interfaces/PageNotificationHistory.md +63 -0
  123. package/doc/interfaces/RenderEmailTemplateRequest.md +44 -0
  124. package/doc/interfaces/RequestArgs.md +58 -0
  125. package/doc/interfaces/RequestDefaultBehaviorGroupPropertyList.md +44 -0
  126. package/doc/interfaces/RequestSystemSubscriptionProperties.md +44 -0
  127. package/doc/interfaces/ServerInfo.md +29 -0
  128. package/doc/interfaces/SettingsValues.md +33 -0
  129. package/doc/interfaces/SettingsValuesByEventType.md +33 -0
  130. package/doc/interfaces/SystemSubscriptionProperties.md +59 -0
  131. package/doc/interfaces/Template.md +104 -0
  132. package/doc/interfaces/TriggerDailyDigestRequest.md +89 -0
  133. package/doc/interfaces/UpdateBehaviorGroupRequest.md +74 -0
  134. package/doc/interfaces/UserConfigPreferences.md +44 -0
  135. package/doc/interfaces/WebhookProperties.md +89 -0
  136. package/doc/modules.md +1080 -0
  137. package/git_push.sh +57 -0
  138. package/openapitools.json +7 -0
  139. package/package.json +26 -31
  140. package/postProcess.sh +3 -11
  141. package/tsconfig-cjs.json +19 -0
  142. package/tsconfig-esm.json +21 -0
  143. package/tsconfig.json +18 -0
  144. package/doc/classes/appregistrationapi.md +0 -123
  145. package/doc/classes/appsapi.md +0 -149
  146. package/doc/classes/baseapi.md +0 -86
  147. package/doc/classes/configuration.md +0 -140
  148. package/doc/classes/endpointsapi.md +0 -255
  149. package/doc/classes/filtersapi.md +0 -124
  150. package/doc/classes/requirederror.md +0 -109
  151. package/doc/enums/app.typeenum.md +0 -28
  152. package/doc/enums/endpoint.typeenum.md +0 -28
  153. package/doc/enums/endpointattributes.lastdeliverystatusenum.md +0 -38
  154. package/doc/enums/eventtype.typeenum.md +0 -28
  155. package/doc/enums/inlineresponse2004data.typeenum.md +0 -28
  156. package/doc/enums/level.typeenum.md +0 -28
  157. package/doc/interfaces/appattributes.md +0 -54
  158. package/doc/interfaces/apprelationships.md +0 -36
  159. package/doc/interfaces/appsregisterapplication.md +0 -50
  160. package/doc/interfaces/appsregistereventtypes.md +0 -64
  161. package/doc/interfaces/appsregistereventtypeslevels.md +0 -50
  162. package/doc/interfaces/configurationparameters.md +0 -84
  163. package/doc/interfaces/endpointsendpoint.md +0 -78
  164. package/doc/interfaces/endpointsendpointfilter.md +0 -64
  165. package/doc/interfaces/endpointsidendpoint.md +0 -78
  166. package/doc/interfaces/endpointsidendpointfilter.md +0 -78
  167. package/doc/interfaces/errors.md +0 -36
  168. package/doc/interfaces/errorserrors.md +0 -120
  169. package/doc/interfaces/errorssource.md +0 -50
  170. package/doc/interfaces/eventtypeattributes.md +0 -54
  171. package/doc/interfaces/eventtyperelationships.md +0 -36
  172. package/doc/interfaces/inlineobject.md +0 -50
  173. package/doc/interfaces/inlineobject1.md +0 -36
  174. package/doc/interfaces/inlineobject2.md +0 -36
  175. package/doc/interfaces/inlineresponse200.md +0 -50
  176. package/doc/interfaces/inlineresponse2001.md +0 -36
  177. package/doc/interfaces/inlineresponse2002.md +0 -50
  178. package/doc/interfaces/inlineresponse2003.md +0 -64
  179. package/doc/interfaces/inlineresponse2004.md +0 -36
  180. package/doc/interfaces/inlineresponse2004dataattributes.md +0 -36
  181. package/doc/interfaces/inlineresponse2004datarelationships.md +0 -78
  182. package/doc/interfaces/inlineresponse201.md +0 -36
  183. package/doc/interfaces/levelattributes.md +0 -38
  184. package/doc/interfaces/links.md +0 -86
  185. package/doc/interfaces/metadata.md +0 -70
  186. package/doc/interfaces/relationship.md +0 -50
  187. package/doc/interfaces/relationships.md +0 -36
  188. package/doc/interfaces/requestargs.md +0 -42
  189. package/doc/modules/app.md +0 -82
  190. package/doc/modules/endpoint.md +0 -68
  191. package/doc/modules/endpointattributes.md +0 -118
  192. package/doc/modules/eventtype.md +0 -82
  193. package/doc/modules/inlineresponse2004data.md +0 -78
  194. package/doc/modules/level.md +0 -68
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Status = exports.NotificationStatus = exports.HttpType = exports.EventLogEntryActionStatus = exports.Environment = exports.EndpointType = exports.EndpointStatus = exports.EmailSubscriptionType = void 0;
4
+ /**
5
+ *
6
+ * @export
7
+ * @enum {string}
8
+ */
9
+ exports.EmailSubscriptionType = {
10
+ Daily: 'DAILY'
11
+ };
12
+ /**
13
+ *
14
+ * @export
15
+ * @enum {string}
16
+ */
17
+ exports.EndpointStatus = {
18
+ Ready: 'READY',
19
+ Unknown: 'UNKNOWN',
20
+ New: 'NEW',
21
+ Provisioning: 'PROVISIONING',
22
+ Deleting: 'DELETING',
23
+ Failed: 'FAILED'
24
+ };
25
+ /**
26
+ *
27
+ * @export
28
+ * @enum {string}
29
+ */
30
+ exports.EndpointType = {
31
+ Webhook: 'webhook',
32
+ EmailSubscription: 'email_subscription',
33
+ Camel: 'camel',
34
+ Ansible: 'ansible',
35
+ Drawer: 'drawer'
36
+ };
37
+ /**
38
+ *
39
+ * @export
40
+ * @enum {string}
41
+ */
42
+ exports.Environment = {
43
+ Prod: 'PROD',
44
+ Stage: 'STAGE',
45
+ Ephemeral: 'EPHEMERAL',
46
+ LocalServer: 'LOCAL_SERVER'
47
+ };
48
+ /**
49
+ *
50
+ * @export
51
+ * @enum {string}
52
+ */
53
+ exports.EventLogEntryActionStatus = {
54
+ Sent: 'SENT',
55
+ Success: 'SUCCESS',
56
+ Processing: 'PROCESSING',
57
+ Failed: 'FAILED',
58
+ Unknown: 'UNKNOWN'
59
+ };
60
+ /**
61
+ *
62
+ * @export
63
+ * @enum {string}
64
+ */
65
+ exports.HttpType = {
66
+ Get: 'GET',
67
+ Post: 'POST',
68
+ Put: 'PUT'
69
+ };
70
+ /**
71
+ *
72
+ * @export
73
+ * @enum {string}
74
+ */
75
+ exports.NotificationStatus = {
76
+ FailedInternal: 'FAILED_INTERNAL',
77
+ FailedExternal: 'FAILED_EXTERNAL',
78
+ Processing: 'PROCESSING',
79
+ Sent: 'SENT',
80
+ Success: 'SUCCESS'
81
+ };
82
+ /**
83
+ *
84
+ * @export
85
+ * @enum {string}
86
+ */
87
+ exports.Status = {
88
+ Up: 'UP',
89
+ Maintenance: 'MAINTENANCE'
90
+ };
@@ -0,0 +1,84 @@
1
+ import type { Configuration } from './configuration';
2
+ import type { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios';
3
+ export declare const BASE_PATH: string;
4
+ /**
5
+ *
6
+ * @export
7
+ */
8
+ export declare const COLLECTION_FORMATS: {
9
+ csv: string;
10
+ ssv: string;
11
+ tsv: string;
12
+ pipes: string;
13
+ };
14
+ /**
15
+ *
16
+ * @export
17
+ * @interface RequestArgs
18
+ */
19
+ export interface RequestArgs {
20
+ urlObj: URL;
21
+ options: AxiosRequestConfig;
22
+ auth?: {
23
+ authType: AuthTypeEnum;
24
+ authKey?: string | [string, string[]];
25
+ }[];
26
+ serializeData?: unknown;
27
+ }
28
+ export interface ApiConfig {
29
+ axios: AxiosInstance;
30
+ configuration?: Configuration;
31
+ }
32
+ export declare const AuthTypeEnum: {
33
+ readonly Basic: "basic";
34
+ readonly Bearer: "bearer";
35
+ readonly Oauth: "oath";
36
+ readonly InHeader: "inHeader";
37
+ readonly InQuery: "inQuery";
38
+ };
39
+ export declare type AuthTypeEnum = typeof AuthTypeEnum[keyof typeof AuthTypeEnum];
40
+ export declare type ActionType = (...config: any) => Promise<RequestArgs>;
41
+ /**
42
+ * Base API to store config, basepath and axios instance.
43
+ * @export
44
+ * @class BaseAPI
45
+ */
46
+ export declare class BaseAPI {
47
+ protected basePath: string;
48
+ protected configuration: Configuration | undefined;
49
+ protected axios: AxiosInstance;
50
+ /**
51
+ * Constructor to create baseAPI.
52
+ * @param { string } basePath basePath of api requests.
53
+ * @param { { axios: AxiosInstance, configuration: Configuration } } config to be passed down to axios.
54
+ */
55
+ constructor(basePath?: string, config?: ApiConfig);
56
+ private authConfig;
57
+ /**
58
+ * Send axios request
59
+ * @param {Promise<RequestArgs>} request to be send trough axios.
60
+ * @param {AxiosInstance} axios optional axios instance.
61
+ * @returns {Promise<AxiosResponse<T>>} promisable axios response.
62
+ */
63
+ sendRequest<T>(request: Promise<RequestArgs>, axios?: AxiosInstance, basePath?: string): Promise<AxiosResponse<T>>;
64
+ }
65
+ /**
66
+ *
67
+ * Factory for creating API with option to add enpoints to the API.
68
+ * @param basePath basePath of api requests.
69
+ * @param { { axios: AxiosInstance, configuration: Configuration } } config to be passed down to axios.
70
+ * @param actions object with actions to send with axios.
71
+ * @returns created base API.
72
+ */
73
+ export declare const APIFactory: <T extends Record<string, ActionType>>(basePath: string, config: ApiConfig, actions: T) => BaseAPI & T;
74
+ export default APIFactory;
75
+ /**
76
+ *
77
+ * @export
78
+ * @class RequiredError
79
+ * @extends {Error}
80
+ */
81
+ export declare class RequiredError extends Error {
82
+ field: string;
83
+ constructor(field: string, msg?: string);
84
+ }
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ var __extends = (this && this.__extends) || (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics = Object.setPrototypeOf ||
7
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9
+ return extendStatics(d, b);
10
+ };
11
+ return function (d, b) {
12
+ if (typeof b !== "function" && b !== null)
13
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
14
+ extendStatics(d, b);
15
+ function __() { this.constructor = d; }
16
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
+ };
18
+ })();
19
+ var __assign = (this && this.__assign) || function () {
20
+ __assign = Object.assign || function(t) {
21
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
22
+ s = arguments[i];
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
24
+ t[p] = s[p];
25
+ }
26
+ return t;
27
+ };
28
+ return __assign.apply(this, arguments);
29
+ };
30
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
31
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
32
+ return new (P || (P = Promise))(function (resolve, reject) {
33
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
34
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
35
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
36
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
37
+ });
38
+ };
39
+ var __generator = (this && this.__generator) || function (thisArg, body) {
40
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
41
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
42
+ function verb(n) { return function (v) { return step([n, v]); }; }
43
+ function step(op) {
44
+ if (f) throw new TypeError("Generator is already executing.");
45
+ while (_) try {
46
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
47
+ if (y = 0, t) op = [op[0] & 2, t.value];
48
+ switch (op[0]) {
49
+ case 0: case 1: t = op; break;
50
+ case 4: _.label++; return { value: op[1], done: false };
51
+ case 5: _.label++; y = op[1]; op = [0]; continue;
52
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
53
+ default:
54
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
55
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
56
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
57
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
58
+ if (t[2]) _.ops.pop();
59
+ _.trys.pop(); continue;
60
+ }
61
+ op = body.call(thisArg, _);
62
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
63
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
64
+ }
65
+ };
66
+ Object.defineProperty(exports, "__esModule", { value: true });
67
+ exports.RequiredError = exports.APIFactory = exports.BaseAPI = exports.AuthTypeEnum = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
68
+ // @ts-ignore
69
+ var common_1 = require("./common");
70
+ var axios_1 = require("axios");
71
+ exports.BASE_PATH = "https://console.redhat.com//api/notifications/v1.0".replace(/\/+$/, "");
72
+ /**
73
+ *
74
+ * @export
75
+ */
76
+ exports.COLLECTION_FORMATS = {
77
+ csv: ",",
78
+ ssv: " ",
79
+ tsv: "\t",
80
+ pipes: "|",
81
+ };
82
+ exports.AuthTypeEnum = {
83
+ Basic: 'basic',
84
+ Bearer: 'bearer',
85
+ Oauth: 'oath',
86
+ InHeader: 'inHeader',
87
+ InQuery: 'inQuery'
88
+ };
89
+ /**
90
+ * Base API to store config, basepath and axios instance.
91
+ * @export
92
+ * @class BaseAPI
93
+ */
94
+ var BaseAPI = /** @class */ (function () {
95
+ /**
96
+ * Constructor to create baseAPI.
97
+ * @param { string } basePath basePath of api requests.
98
+ * @param { { axios: AxiosInstance, configuration: Configuration } } config to be passed down to axios.
99
+ */
100
+ function BaseAPI(basePath, config) {
101
+ if (basePath === void 0) { basePath = exports.BASE_PATH; }
102
+ if (config === void 0) { config = { axios: axios_1.default }; }
103
+ this.basePath = basePath;
104
+ this.axios = config.axios;
105
+ if (config.configuration) {
106
+ this.configuration = config.configuration;
107
+ this.basePath = config.configuration.basePath || this.basePath;
108
+ }
109
+ // Object.entries(actions).forEach((entry: [string, ActionType]) => {
110
+ // Object.assign(this, {
111
+ // [entry[0]]: entry[1]
112
+ // })
113
+ // })
114
+ }
115
+ BaseAPI.prototype.authConfig = function (_a) {
116
+ var authType = _a.authType, urlObj = _a.urlObj, options = _a.options, authKey = _a.authKey;
117
+ return __awaiter(this, void 0, void 0, function () {
118
+ var localVarQueryParameter, localVarHeaderParameter, localVarHeaderParameter, localVarHeaderParameter;
119
+ return __generator(this, function (_b) {
120
+ switch (_b.label) {
121
+ case 0:
122
+ if (!(authType === exports.AuthTypeEnum.InQuery && typeof authKey === 'string')) return [3 /*break*/, 2];
123
+ localVarQueryParameter = {};
124
+ return [4 /*yield*/, (0, common_1.setApiKeyToObject)(localVarQueryParameter, authKey, this.configuration)];
125
+ case 1:
126
+ _b.sent();
127
+ (0, common_1.setSearchParams)(urlObj, localVarQueryParameter);
128
+ return [3 /*break*/, 9];
129
+ case 2:
130
+ if (!(authType === exports.AuthTypeEnum.InHeader && typeof authKey === 'string')) return [3 /*break*/, 4];
131
+ localVarHeaderParameter = {};
132
+ return [4 /*yield*/, (0, common_1.setApiKeyToObject)(localVarHeaderParameter, authKey, this.configuration)];
133
+ case 3:
134
+ _b.sent();
135
+ options.headers = __assign(__assign({}, options.headers), localVarHeaderParameter);
136
+ return [3 /*break*/, 9];
137
+ case 4:
138
+ if (!(authType === exports.AuthTypeEnum.Basic)) return [3 /*break*/, 5];
139
+ (0, common_1.setBasicAuthToObject)(options, this.configuration);
140
+ return [3 /*break*/, 9];
141
+ case 5:
142
+ if (!(authType === exports.AuthTypeEnum.Bearer)) return [3 /*break*/, 7];
143
+ localVarHeaderParameter = {};
144
+ return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, this.configuration)];
145
+ case 6:
146
+ _b.sent();
147
+ options.headers = __assign(__assign({}, options.headers), localVarHeaderParameter);
148
+ return [3 /*break*/, 9];
149
+ case 7:
150
+ if (!(authType === exports.AuthTypeEnum.Oauth)) return [3 /*break*/, 9];
151
+ localVarHeaderParameter = {};
152
+ return [4 /*yield*/, (0, common_1.setOAuthToObject)(localVarHeaderParameter, authKey[0], authKey[1], this.configuration)];
153
+ case 8:
154
+ _b.sent();
155
+ options.headers = __assign(__assign({}, options.headers), localVarHeaderParameter);
156
+ _b.label = 9;
157
+ case 9: return [2 /*return*/];
158
+ }
159
+ });
160
+ });
161
+ };
162
+ /**
163
+ * Send axios request
164
+ * @param {Promise<RequestArgs>} request to be send trough axios.
165
+ * @param {AxiosInstance} axios optional axios instance.
166
+ * @returns {Promise<AxiosResponse<T>>} promisable axios response.
167
+ */
168
+ BaseAPI.prototype.sendRequest = function (request, axios, basePath) {
169
+ return __awaiter(this, void 0, void 0, function () {
170
+ var _a, auth, urlObj, options, serializeData, axiosRequestArgs;
171
+ var _this = this;
172
+ return __generator(this, function (_b) {
173
+ switch (_b.label) {
174
+ case 0: return [4 /*yield*/, request];
175
+ case 1:
176
+ _a = _b.sent(), auth = _a.auth, urlObj = _a.urlObj, options = _a.options, serializeData = _a.serializeData;
177
+ auth === null || auth === void 0 ? void 0 : auth.forEach(function (_a) {
178
+ var authType = _a.authType, authKey = _a.authKey;
179
+ return __awaiter(_this, void 0, void 0, function () {
180
+ return __generator(this, function (_b) {
181
+ switch (_b.label) {
182
+ case 0: return [4 /*yield*/, this.authConfig({ authType: authType, urlObj: urlObj, options: options, authKey: authKey })];
183
+ case 1:
184
+ _b.sent();
185
+ return [2 /*return*/];
186
+ }
187
+ });
188
+ });
189
+ });
190
+ if (serializeData) {
191
+ options.data = (0, common_1.serializeDataIfNeeded)(serializeData, options, this.configuration);
192
+ }
193
+ axiosRequestArgs = __assign(__assign({}, options), { url: (this.basePath || basePath) + (0, common_1.toPathString)(urlObj) });
194
+ return [2 /*return*/, (axios || this.axios).request(axiosRequestArgs)];
195
+ }
196
+ });
197
+ });
198
+ };
199
+ return BaseAPI;
200
+ }());
201
+ exports.BaseAPI = BaseAPI;
202
+ ;
203
+ /**
204
+ *
205
+ * Factory for creating API with option to add enpoints to the API.
206
+ * @param basePath basePath of api requests.
207
+ * @param { { axios: AxiosInstance, configuration: Configuration } } config to be passed down to axios.
208
+ * @param actions object with actions to send with axios.
209
+ * @returns created base API.
210
+ */
211
+ var APIFactory = function (basePath, config, actions) {
212
+ if (basePath === void 0) { basePath = exports.BASE_PATH; }
213
+ if (config === void 0) { config = { axios: axios_1.default }; }
214
+ var api = new BaseAPI(basePath, config);
215
+ var _loop_1 = function (key) {
216
+ var _b;
217
+ var method = actions[key];
218
+ Object.assign(api, (_b = {}, _b[key] = function () {
219
+ var args = [];
220
+ for (var _i = 0; _i < arguments.length; _i++) {
221
+ args[_i] = arguments[_i];
222
+ }
223
+ var request = method.apply(void 0, args);
224
+ return api.sendRequest(request);
225
+ }, _b));
226
+ };
227
+ for (var _i = 0, _a = Object.keys(actions); _i < _a.length; _i++) {
228
+ var key = _a[_i];
229
+ _loop_1(key);
230
+ }
231
+ return api;
232
+ };
233
+ exports.APIFactory = APIFactory;
234
+ exports.default = exports.APIFactory;
235
+ /**
236
+ *
237
+ * @export
238
+ * @class RequiredError
239
+ * @extends {Error}
240
+ */
241
+ var RequiredError = /** @class */ (function (_super) {
242
+ __extends(RequiredError, _super);
243
+ function RequiredError(field, msg) {
244
+ var _this = _super.call(this, msg) || this;
245
+ _this.field = field;
246
+ _this.name = "RequiredError";
247
+ return _this;
248
+ }
249
+ return RequiredError;
250
+ }(Error));
251
+ exports.RequiredError = RequiredError;
@@ -0,0 +1,54 @@
1
+ import type { Configuration } from "./configuration";
2
+ import type { RequestArgs } from "./base";
3
+ import type { AxiosInstance, AxiosResponse } from 'axios';
4
+ /**
5
+ *
6
+ * @export
7
+ */
8
+ export declare const DUMMY_BASE_URL = "https://example.com";
9
+ /**
10
+ *
11
+ * @throws {RequiredError}
12
+ * @export
13
+ */
14
+ export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
15
+ /**
16
+ *
17
+ * @export
18
+ */
19
+ export declare const setApiKeyToObject: (object: any, keyParamName: string, configuration?: Configuration) => Promise<void>;
20
+ /**
21
+ *
22
+ * @export
23
+ */
24
+ export declare const setBasicAuthToObject: (object: any, configuration?: Configuration) => void;
25
+ /**
26
+ *
27
+ * @export
28
+ */
29
+ export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
30
+ /**
31
+ *
32
+ * @export
33
+ */
34
+ export declare const setOAuthToObject: (object: any, name: string, scopes: string[], configuration?: Configuration) => Promise<void>;
35
+ /**
36
+ *
37
+ * @export
38
+ */
39
+ export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
40
+ /**
41
+ *
42
+ * @export
43
+ */
44
+ export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
45
+ /**
46
+ *
47
+ * @export
48
+ */
49
+ export declare const toPathString: (url: URL) => string;
50
+ /**
51
+ *
52
+ * @export
53
+ */
54
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;