emailagent-sdk 0.1.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.
- package/README.md +41 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +95 -0
- package/generated/.openapi-generator/FILES +41 -0
- package/generated/.openapi-generator/VERSION +1 -0
- package/generated/.openapi-generator-ignore +23 -0
- package/generated/package.json +21 -0
- package/generated/src/apis/APIKeysApi.ts +314 -0
- package/generated/src/apis/DomainsApi.ts +314 -0
- package/generated/src/apis/EmailsApi.ts +350 -0
- package/generated/src/apis/InboxesApi.ts +329 -0
- package/generated/src/apis/MetricsApi.ts +93 -0
- package/generated/src/apis/index.ts +7 -0
- package/generated/src/index.ts +5 -0
- package/generated/src/models/ApiKeyCreated.ts +123 -0
- package/generated/src/models/ApiKeyCreatedResponse.ts +74 -0
- package/generated/src/models/ApiKeyListItem.ts +121 -0
- package/generated/src/models/ApiKeyListResponse.ts +74 -0
- package/generated/src/models/CreateApiKeyRequest.ts +82 -0
- package/generated/src/models/CreateApiKeyRequestScopes.ts +45 -0
- package/generated/src/models/CreateDomainRequest.ts +66 -0
- package/generated/src/models/CreateInboxRequest.ts +82 -0
- package/generated/src/models/Domain.ts +152 -0
- package/generated/src/models/DomainListResponse.ts +74 -0
- package/generated/src/models/DomainResponse.ts +74 -0
- package/generated/src/models/Email.ts +222 -0
- package/generated/src/models/EmailListResponse.ts +74 -0
- package/generated/src/models/EmailResponse.ts +74 -0
- package/generated/src/models/ErrorResponse.ts +66 -0
- package/generated/src/models/Inbox.ts +159 -0
- package/generated/src/models/InboxListResponse.ts +74 -0
- package/generated/src/models/InboxResponse.ts +74 -0
- package/generated/src/models/MetricsData.ts +139 -0
- package/generated/src/models/MetricsResponse.ts +74 -0
- package/generated/src/models/OkResponse.ts +66 -0
- package/generated/src/models/PlanLimits.ts +93 -0
- package/generated/src/models/SendEmailRequest.ts +91 -0
- package/generated/src/models/UpdateEmailReadRequest.ts +66 -0
- package/generated/src/models/UpdateInboxRequest.ts +66 -0
- package/generated/src/models/index.ts +27 -0
- package/generated/src/runtime.ts +432 -0
- package/generated/tsconfig.esm.json +7 -0
- package/generated/tsconfig.json +16 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# emailagent-sdk (TypeScript)
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for EmailAgent.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install emailagent-sdk@0.1.0
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { EmailAgentClient } from 'emailagent-sdk';
|
|
15
|
+
|
|
16
|
+
const client = new EmailAgentClient({
|
|
17
|
+
apiKey: process.env.EMAILAGENT_API_KEY!,
|
|
18
|
+
baseUrl: 'https://api.emailagent.dev'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const inboxes = await client.listInboxes();
|
|
22
|
+
console.log(inboxes.data);
|
|
23
|
+
|
|
24
|
+
const emails = await client.listEmails({ inboxId: '<inbox_uuid>' });
|
|
25
|
+
console.log(emails.data);
|
|
26
|
+
|
|
27
|
+
await client.updateEmailRead('<email_uuid>', true, {
|
|
28
|
+
idempotencyKey: 'mark-read-001'
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Idempotency
|
|
33
|
+
|
|
34
|
+
Pass `idempotencyKey` for mutating calls:
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
await client.createInbox(
|
|
38
|
+
{ localPart: 'agent-1' },
|
|
39
|
+
{ idempotencyKey: 'create-inbox-agent-1' }
|
|
40
|
+
);
|
|
41
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type HttpMethod = 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
2
|
+
export interface EmailAgentClientOptions {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
fetchImpl?: typeof fetch;
|
|
6
|
+
}
|
|
7
|
+
export interface RequestOptions {
|
|
8
|
+
idempotencyKey?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ApiErrorBody {
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class EmailAgentApiError extends Error {
|
|
14
|
+
status: number;
|
|
15
|
+
body: ApiErrorBody | string | null;
|
|
16
|
+
constructor(status: number, body: ApiErrorBody | string | null);
|
|
17
|
+
}
|
|
18
|
+
export declare class EmailAgentClient {
|
|
19
|
+
private readonly baseUrl;
|
|
20
|
+
private readonly apiKey;
|
|
21
|
+
private readonly fetchImpl;
|
|
22
|
+
constructor(options: EmailAgentClientOptions);
|
|
23
|
+
private request;
|
|
24
|
+
listInboxes(): Promise<{
|
|
25
|
+
data: unknown[];
|
|
26
|
+
}>;
|
|
27
|
+
createInbox(payload: {
|
|
28
|
+
localPart: string;
|
|
29
|
+
displayName?: string;
|
|
30
|
+
domainName?: string;
|
|
31
|
+
}, options?: RequestOptions): Promise<{
|
|
32
|
+
data: unknown;
|
|
33
|
+
}>;
|
|
34
|
+
updateInbox(id: string, payload: {
|
|
35
|
+
displayName: string;
|
|
36
|
+
}, options?: RequestOptions): Promise<{
|
|
37
|
+
data: unknown;
|
|
38
|
+
}>;
|
|
39
|
+
deleteInbox(id: string, options?: RequestOptions): Promise<{
|
|
40
|
+
ok: true;
|
|
41
|
+
}>;
|
|
42
|
+
sendEmail(payload: {
|
|
43
|
+
inboxId: string;
|
|
44
|
+
to: string;
|
|
45
|
+
subject?: string;
|
|
46
|
+
text?: string;
|
|
47
|
+
}, options?: RequestOptions): Promise<{
|
|
48
|
+
data: unknown;
|
|
49
|
+
}>;
|
|
50
|
+
listEmails(params?: {
|
|
51
|
+
inboxId?: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
data: unknown[];
|
|
54
|
+
}>;
|
|
55
|
+
updateEmailRead(id: string, isRead: boolean, options?: RequestOptions): Promise<{
|
|
56
|
+
data: unknown;
|
|
57
|
+
}>;
|
|
58
|
+
deleteEmail(id: string, options?: RequestOptions): Promise<{
|
|
59
|
+
ok: true;
|
|
60
|
+
}>;
|
|
61
|
+
listDomains(): Promise<{
|
|
62
|
+
data: unknown[];
|
|
63
|
+
}>;
|
|
64
|
+
createDomain(payload: {
|
|
65
|
+
name: string;
|
|
66
|
+
}, options?: RequestOptions): Promise<{
|
|
67
|
+
data: unknown;
|
|
68
|
+
}>;
|
|
69
|
+
verifyDomain(id: string, options?: RequestOptions): Promise<{
|
|
70
|
+
data: unknown;
|
|
71
|
+
}>;
|
|
72
|
+
deleteDomain(id: string, options?: RequestOptions): Promise<{
|
|
73
|
+
ok: true;
|
|
74
|
+
}>;
|
|
75
|
+
listApiKeys(): Promise<{
|
|
76
|
+
data: unknown[];
|
|
77
|
+
}>;
|
|
78
|
+
createApiKey(payload: {
|
|
79
|
+
name: string;
|
|
80
|
+
scopes?: string[] | string;
|
|
81
|
+
}, options?: RequestOptions): Promise<{
|
|
82
|
+
data: unknown;
|
|
83
|
+
}>;
|
|
84
|
+
rotateApiKey(id: string, options?: RequestOptions): Promise<{
|
|
85
|
+
data: unknown;
|
|
86
|
+
}>;
|
|
87
|
+
revokeApiKey(id: string, options?: RequestOptions): Promise<{
|
|
88
|
+
ok: true;
|
|
89
|
+
}>;
|
|
90
|
+
getMetrics(): Promise<{
|
|
91
|
+
data: unknown;
|
|
92
|
+
}>;
|
|
93
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export class EmailAgentApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
body;
|
|
4
|
+
constructor(status, body) {
|
|
5
|
+
const message = typeof body === 'object' && body?.error ? body.error : `EmailAgent API error (${status})`;
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'EmailAgentApiError';
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.body = body;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class EmailAgentClient {
|
|
13
|
+
baseUrl;
|
|
14
|
+
apiKey;
|
|
15
|
+
fetchImpl;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.baseUrl = (options.baseUrl ?? 'https://api.emailagent.dev').replace(/\/$/, '');
|
|
18
|
+
this.apiKey = options.apiKey;
|
|
19
|
+
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
20
|
+
}
|
|
21
|
+
async request(method, path, body, options) {
|
|
22
|
+
const headers = {
|
|
23
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
24
|
+
};
|
|
25
|
+
if (body !== undefined) {
|
|
26
|
+
headers['Content-Type'] = 'application/json';
|
|
27
|
+
}
|
|
28
|
+
if (options?.idempotencyKey) {
|
|
29
|
+
headers['Idempotency-Key'] = options.idempotencyKey;
|
|
30
|
+
}
|
|
31
|
+
const response = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
32
|
+
method,
|
|
33
|
+
headers,
|
|
34
|
+
body: body === undefined ? undefined : JSON.stringify(body)
|
|
35
|
+
});
|
|
36
|
+
const text = await response.text();
|
|
37
|
+
const parsed = text ? JSON.parse(text) : null;
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
throw new EmailAgentApiError(response.status, parsed);
|
|
40
|
+
}
|
|
41
|
+
return parsed;
|
|
42
|
+
}
|
|
43
|
+
listInboxes() {
|
|
44
|
+
return this.request('GET', '/api/v1/inboxes');
|
|
45
|
+
}
|
|
46
|
+
createInbox(payload, options) {
|
|
47
|
+
return this.request('POST', '/api/v1/inboxes', payload, options);
|
|
48
|
+
}
|
|
49
|
+
updateInbox(id, payload, options) {
|
|
50
|
+
return this.request('PATCH', `/api/v1/inboxes/${id}`, payload, options);
|
|
51
|
+
}
|
|
52
|
+
deleteInbox(id, options) {
|
|
53
|
+
return this.request('DELETE', `/api/v1/inboxes/${id}`, undefined, options);
|
|
54
|
+
}
|
|
55
|
+
sendEmail(payload, options) {
|
|
56
|
+
return this.request('POST', '/api/v1/emails/send', payload, options);
|
|
57
|
+
}
|
|
58
|
+
listEmails(params) {
|
|
59
|
+
const query = params?.inboxId ? `?inboxId=${encodeURIComponent(params.inboxId)}` : '';
|
|
60
|
+
return this.request('GET', `/api/v1/emails${query}`);
|
|
61
|
+
}
|
|
62
|
+
updateEmailRead(id, isRead, options) {
|
|
63
|
+
return this.request('PATCH', `/api/v1/emails/${id}/read`, { isRead }, options);
|
|
64
|
+
}
|
|
65
|
+
deleteEmail(id, options) {
|
|
66
|
+
return this.request('DELETE', `/api/v1/emails/${id}`, undefined, options);
|
|
67
|
+
}
|
|
68
|
+
listDomains() {
|
|
69
|
+
return this.request('GET', '/api/v1/domains');
|
|
70
|
+
}
|
|
71
|
+
createDomain(payload, options) {
|
|
72
|
+
return this.request('POST', '/api/v1/domains', payload, options);
|
|
73
|
+
}
|
|
74
|
+
verifyDomain(id, options) {
|
|
75
|
+
return this.request('POST', `/api/v1/domains/${id}/verify`, undefined, options);
|
|
76
|
+
}
|
|
77
|
+
deleteDomain(id, options) {
|
|
78
|
+
return this.request('DELETE', `/api/v1/domains/${id}`, undefined, options);
|
|
79
|
+
}
|
|
80
|
+
listApiKeys() {
|
|
81
|
+
return this.request('GET', '/api/v1/api-keys');
|
|
82
|
+
}
|
|
83
|
+
createApiKey(payload, options) {
|
|
84
|
+
return this.request('POST', '/api/v1/api-keys', payload, options);
|
|
85
|
+
}
|
|
86
|
+
rotateApiKey(id, options) {
|
|
87
|
+
return this.request('POST', `/api/v1/api-keys/${id}/rotate`, undefined, options);
|
|
88
|
+
}
|
|
89
|
+
revokeApiKey(id, options) {
|
|
90
|
+
return this.request('POST', `/api/v1/api-keys/${id}/revoke`, undefined, options);
|
|
91
|
+
}
|
|
92
|
+
getMetrics() {
|
|
93
|
+
return this.request('GET', '/api/v1/metrics');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.gitignore
|
|
2
|
+
.npmignore
|
|
3
|
+
.openapi-generator-ignore
|
|
4
|
+
README.md
|
|
5
|
+
package.json
|
|
6
|
+
src/apis/APIKeysApi.ts
|
|
7
|
+
src/apis/DomainsApi.ts
|
|
8
|
+
src/apis/EmailsApi.ts
|
|
9
|
+
src/apis/InboxesApi.ts
|
|
10
|
+
src/apis/MetricsApi.ts
|
|
11
|
+
src/apis/index.ts
|
|
12
|
+
src/index.ts
|
|
13
|
+
src/models/ApiKeyCreated.ts
|
|
14
|
+
src/models/ApiKeyCreatedResponse.ts
|
|
15
|
+
src/models/ApiKeyListItem.ts
|
|
16
|
+
src/models/ApiKeyListResponse.ts
|
|
17
|
+
src/models/CreateApiKeyRequest.ts
|
|
18
|
+
src/models/CreateApiKeyRequestScopes.ts
|
|
19
|
+
src/models/CreateDomainRequest.ts
|
|
20
|
+
src/models/CreateInboxRequest.ts
|
|
21
|
+
src/models/Domain.ts
|
|
22
|
+
src/models/DomainListResponse.ts
|
|
23
|
+
src/models/DomainResponse.ts
|
|
24
|
+
src/models/Email.ts
|
|
25
|
+
src/models/EmailListResponse.ts
|
|
26
|
+
src/models/EmailResponse.ts
|
|
27
|
+
src/models/ErrorResponse.ts
|
|
28
|
+
src/models/Inbox.ts
|
|
29
|
+
src/models/InboxListResponse.ts
|
|
30
|
+
src/models/InboxResponse.ts
|
|
31
|
+
src/models/MetricsData.ts
|
|
32
|
+
src/models/MetricsResponse.ts
|
|
33
|
+
src/models/OkResponse.ts
|
|
34
|
+
src/models/PlanLimits.ts
|
|
35
|
+
src/models/SendEmailRequest.ts
|
|
36
|
+
src/models/UpdateEmailReadRequest.ts
|
|
37
|
+
src/models/UpdateInboxRequest.ts
|
|
38
|
+
src/models/index.ts
|
|
39
|
+
src/runtime.ts
|
|
40
|
+
tsconfig.esm.json
|
|
41
|
+
tsconfig.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
7.14.0
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# OpenAPI Generator Ignore
|
|
2
|
+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
|
3
|
+
|
|
4
|
+
# Use this file to prevent files from being overwritten by the generator.
|
|
5
|
+
# The patterns follow closely to .gitignore or .dockerignore.
|
|
6
|
+
|
|
7
|
+
# As an example, the C# client generator defines ApiClient.cs.
|
|
8
|
+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
|
9
|
+
#ApiClient.cs
|
|
10
|
+
|
|
11
|
+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
|
12
|
+
#foo/*/qux
|
|
13
|
+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
|
14
|
+
|
|
15
|
+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
|
16
|
+
#foo/**/qux
|
|
17
|
+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
|
18
|
+
|
|
19
|
+
# You can also negate patterns with an exclamation (!).
|
|
20
|
+
# For example, you can ignore all files in a docs folder with the file extension .md:
|
|
21
|
+
#docs/*.md
|
|
22
|
+
# Then explicitly reverse the ignore rule for a single file:
|
|
23
|
+
#!docs/README.md
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "emailagent-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenAPI client for emailagent-sdk",
|
|
5
|
+
"author": "OpenAPI-Generator",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"typings": "./dist/index.d.ts",
|
|
12
|
+
"module": "./dist/esm/index.js",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc && tsc -p tsconfig.esm.json",
|
|
16
|
+
"prepare": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^4.0 || ^5.0"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EmailAgent API
|
|
5
|
+
* API for creating agent inboxes, sending emails, managing custom domains, managing API keys, and reading usage metrics. Authentication uses API keys via `Authorization: Bearer <api_key>`. For mutating endpoints, send an optional `Idempotency-Key` header. - Replaying the same key with the same payload returns the original response. - Reusing a key with a different payload returns `409`.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import * as runtime from '../runtime';
|
|
17
|
+
import type {
|
|
18
|
+
ApiKeyCreatedResponse,
|
|
19
|
+
ApiKeyListResponse,
|
|
20
|
+
CreateApiKeyRequest,
|
|
21
|
+
ErrorResponse,
|
|
22
|
+
OkResponse,
|
|
23
|
+
} from '../models/index';
|
|
24
|
+
import {
|
|
25
|
+
ApiKeyCreatedResponseFromJSON,
|
|
26
|
+
ApiKeyCreatedResponseToJSON,
|
|
27
|
+
ApiKeyListResponseFromJSON,
|
|
28
|
+
ApiKeyListResponseToJSON,
|
|
29
|
+
CreateApiKeyRequestFromJSON,
|
|
30
|
+
CreateApiKeyRequestToJSON,
|
|
31
|
+
ErrorResponseFromJSON,
|
|
32
|
+
ErrorResponseToJSON,
|
|
33
|
+
OkResponseFromJSON,
|
|
34
|
+
OkResponseToJSON,
|
|
35
|
+
} from '../models/index';
|
|
36
|
+
|
|
37
|
+
export interface CreateApiKeyOperationRequest {
|
|
38
|
+
createApiKeyRequest: CreateApiKeyRequest;
|
|
39
|
+
idempotencyKey?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RevokeApiKeyRequest {
|
|
43
|
+
id: string;
|
|
44
|
+
idempotencyKey?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface RotateApiKeyRequest {
|
|
48
|
+
id: string;
|
|
49
|
+
idempotencyKey?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* APIKeysApi - interface
|
|
54
|
+
*
|
|
55
|
+
* @export
|
|
56
|
+
* @interface APIKeysApiInterface
|
|
57
|
+
*/
|
|
58
|
+
export interface APIKeysApiInterface {
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @summary Create API key
|
|
62
|
+
* @param {CreateApiKeyRequest} createApiKeyRequest
|
|
63
|
+
* @param {string} [idempotencyKey] Optional key for safe retries of mutating operations.
|
|
64
|
+
* @param {*} [options] Override http request option.
|
|
65
|
+
* @throws {RequiredError}
|
|
66
|
+
* @memberof APIKeysApiInterface
|
|
67
|
+
*/
|
|
68
|
+
createApiKeyRaw(requestParameters: CreateApiKeyOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApiKeyCreatedResponse>>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create API key
|
|
72
|
+
*/
|
|
73
|
+
createApiKey(requestParameters: CreateApiKeyOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApiKeyCreatedResponse>;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @summary List API keys
|
|
78
|
+
* @param {*} [options] Override http request option.
|
|
79
|
+
* @throws {RequiredError}
|
|
80
|
+
* @memberof APIKeysApiInterface
|
|
81
|
+
*/
|
|
82
|
+
listApiKeysRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApiKeyListResponse>>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* List API keys
|
|
86
|
+
*/
|
|
87
|
+
listApiKeys(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApiKeyListResponse>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* @summary Revoke API key
|
|
92
|
+
* @param {string} id
|
|
93
|
+
* @param {string} [idempotencyKey] Optional key for safe retries of mutating operations.
|
|
94
|
+
* @param {*} [options] Override http request option.
|
|
95
|
+
* @throws {RequiredError}
|
|
96
|
+
* @memberof APIKeysApiInterface
|
|
97
|
+
*/
|
|
98
|
+
revokeApiKeyRaw(requestParameters: RevokeApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OkResponse>>;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Revoke API key
|
|
102
|
+
*/
|
|
103
|
+
revokeApiKey(requestParameters: RevokeApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OkResponse>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @summary Rotate API key (creates new key and revokes old key)
|
|
108
|
+
* @param {string} id
|
|
109
|
+
* @param {string} [idempotencyKey] Optional key for safe retries of mutating operations.
|
|
110
|
+
* @param {*} [options] Override http request option.
|
|
111
|
+
* @throws {RequiredError}
|
|
112
|
+
* @memberof APIKeysApiInterface
|
|
113
|
+
*/
|
|
114
|
+
rotateApiKeyRaw(requestParameters: RotateApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApiKeyCreatedResponse>>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Rotate API key (creates new key and revokes old key)
|
|
118
|
+
*/
|
|
119
|
+
rotateApiKey(requestParameters: RotateApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApiKeyCreatedResponse>;
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
*
|
|
125
|
+
*/
|
|
126
|
+
export class APIKeysApi extends runtime.BaseAPI implements APIKeysApiInterface {
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Create API key
|
|
130
|
+
*/
|
|
131
|
+
async createApiKeyRaw(requestParameters: CreateApiKeyOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApiKeyCreatedResponse>> {
|
|
132
|
+
if (requestParameters['createApiKeyRequest'] == null) {
|
|
133
|
+
throw new runtime.RequiredError(
|
|
134
|
+
'createApiKeyRequest',
|
|
135
|
+
'Required parameter "createApiKeyRequest" was null or undefined when calling createApiKey().'
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const queryParameters: any = {};
|
|
140
|
+
|
|
141
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
142
|
+
|
|
143
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
144
|
+
|
|
145
|
+
if (requestParameters['idempotencyKey'] != null) {
|
|
146
|
+
headerParameters['Idempotency-Key'] = String(requestParameters['idempotencyKey']);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
150
|
+
const token = this.configuration.accessToken;
|
|
151
|
+
const tokenString = await token("bearerAuth", []);
|
|
152
|
+
|
|
153
|
+
if (tokenString) {
|
|
154
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let urlPath = `/api/v1/api-keys`;
|
|
159
|
+
|
|
160
|
+
const response = await this.request({
|
|
161
|
+
path: urlPath,
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers: headerParameters,
|
|
164
|
+
query: queryParameters,
|
|
165
|
+
body: CreateApiKeyRequestToJSON(requestParameters['createApiKeyRequest']),
|
|
166
|
+
}, initOverrides);
|
|
167
|
+
|
|
168
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => ApiKeyCreatedResponseFromJSON(jsonValue));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Create API key
|
|
173
|
+
*/
|
|
174
|
+
async createApiKey(requestParameters: CreateApiKeyOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApiKeyCreatedResponse> {
|
|
175
|
+
const response = await this.createApiKeyRaw(requestParameters, initOverrides);
|
|
176
|
+
return await response.value();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* List API keys
|
|
181
|
+
*/
|
|
182
|
+
async listApiKeysRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApiKeyListResponse>> {
|
|
183
|
+
const queryParameters: any = {};
|
|
184
|
+
|
|
185
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
186
|
+
|
|
187
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
188
|
+
const token = this.configuration.accessToken;
|
|
189
|
+
const tokenString = await token("bearerAuth", []);
|
|
190
|
+
|
|
191
|
+
if (tokenString) {
|
|
192
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
let urlPath = `/api/v1/api-keys`;
|
|
197
|
+
|
|
198
|
+
const response = await this.request({
|
|
199
|
+
path: urlPath,
|
|
200
|
+
method: 'GET',
|
|
201
|
+
headers: headerParameters,
|
|
202
|
+
query: queryParameters,
|
|
203
|
+
}, initOverrides);
|
|
204
|
+
|
|
205
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => ApiKeyListResponseFromJSON(jsonValue));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* List API keys
|
|
210
|
+
*/
|
|
211
|
+
async listApiKeys(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApiKeyListResponse> {
|
|
212
|
+
const response = await this.listApiKeysRaw(initOverrides);
|
|
213
|
+
return await response.value();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Revoke API key
|
|
218
|
+
*/
|
|
219
|
+
async revokeApiKeyRaw(requestParameters: RevokeApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OkResponse>> {
|
|
220
|
+
if (requestParameters['id'] == null) {
|
|
221
|
+
throw new runtime.RequiredError(
|
|
222
|
+
'id',
|
|
223
|
+
'Required parameter "id" was null or undefined when calling revokeApiKey().'
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const queryParameters: any = {};
|
|
228
|
+
|
|
229
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
230
|
+
|
|
231
|
+
if (requestParameters['idempotencyKey'] != null) {
|
|
232
|
+
headerParameters['Idempotency-Key'] = String(requestParameters['idempotencyKey']);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
236
|
+
const token = this.configuration.accessToken;
|
|
237
|
+
const tokenString = await token("bearerAuth", []);
|
|
238
|
+
|
|
239
|
+
if (tokenString) {
|
|
240
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
let urlPath = `/api/v1/api-keys/{id}/revoke`;
|
|
245
|
+
urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));
|
|
246
|
+
|
|
247
|
+
const response = await this.request({
|
|
248
|
+
path: urlPath,
|
|
249
|
+
method: 'POST',
|
|
250
|
+
headers: headerParameters,
|
|
251
|
+
query: queryParameters,
|
|
252
|
+
}, initOverrides);
|
|
253
|
+
|
|
254
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => OkResponseFromJSON(jsonValue));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Revoke API key
|
|
259
|
+
*/
|
|
260
|
+
async revokeApiKey(requestParameters: RevokeApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OkResponse> {
|
|
261
|
+
const response = await this.revokeApiKeyRaw(requestParameters, initOverrides);
|
|
262
|
+
return await response.value();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Rotate API key (creates new key and revokes old key)
|
|
267
|
+
*/
|
|
268
|
+
async rotateApiKeyRaw(requestParameters: RotateApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ApiKeyCreatedResponse>> {
|
|
269
|
+
if (requestParameters['id'] == null) {
|
|
270
|
+
throw new runtime.RequiredError(
|
|
271
|
+
'id',
|
|
272
|
+
'Required parameter "id" was null or undefined when calling rotateApiKey().'
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const queryParameters: any = {};
|
|
277
|
+
|
|
278
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
279
|
+
|
|
280
|
+
if (requestParameters['idempotencyKey'] != null) {
|
|
281
|
+
headerParameters['Idempotency-Key'] = String(requestParameters['idempotencyKey']);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
285
|
+
const token = this.configuration.accessToken;
|
|
286
|
+
const tokenString = await token("bearerAuth", []);
|
|
287
|
+
|
|
288
|
+
if (tokenString) {
|
|
289
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
let urlPath = `/api/v1/api-keys/{id}/rotate`;
|
|
294
|
+
urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));
|
|
295
|
+
|
|
296
|
+
const response = await this.request({
|
|
297
|
+
path: urlPath,
|
|
298
|
+
method: 'POST',
|
|
299
|
+
headers: headerParameters,
|
|
300
|
+
query: queryParameters,
|
|
301
|
+
}, initOverrides);
|
|
302
|
+
|
|
303
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => ApiKeyCreatedResponseFromJSON(jsonValue));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Rotate API key (creates new key and revokes old key)
|
|
308
|
+
*/
|
|
309
|
+
async rotateApiKey(requestParameters: RotateApiKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ApiKeyCreatedResponse> {
|
|
310
|
+
const response = await this.rotateApiKeyRaw(requestParameters, initOverrides);
|
|
311
|
+
return await response.value();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
}
|