-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnamespaces.ts
More file actions
149 lines (127 loc) · 4.17 KB
/
Copy pathnamespaces.ts
File metadata and controls
149 lines (127 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import * as ServersAPI from './servers';
import { ServerCreateParams, ServerCreateResponse, Servers } from './servers';
import { APIPromise } from '../../core/api-promise';
import { NamespacesPage, type NamespacesPageParams, PagePromise } from '../../core/pagination';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
export class Namespaces extends APIResource {
servers: ServersAPI.Servers = new ServersAPI.Servers(this._client);
/**
* Create a new namespace with a server-generated human-readable name, owned by the
* authenticated user
*
* @example
* ```ts
* const namespace = await client.namespaces.create();
* ```
*/
create(options?: RequestOptions): APIPromise<NamespaceCreateResponse> {
return this._client.post('/namespaces', options);
}
/**
* When called without query params, returns the authenticated user's namespaces
* (backwards compatible). When query params are provided, searches public
* namespaces with pagination. Use ownerId to filter by owner, hasServers/hasSkills
* to filter by content, q for text search.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const namespaceListResponse of client.namespaces.list()) {
* // ...
* }
* ```
*/
list(
query: NamespaceListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<NamespaceListResponsesNamespacesPage, NamespaceListResponse> {
return this._client.getAPIList('/namespaces', NamespacesPage<NamespaceListResponse>, {
query,
...options,
});
}
/**
* Delete a namespace owned by the authenticated user. The namespace must not
* contain any servers. Skills and connections in the namespace will be deleted
* automatically.
*
* @example
* ```ts
* const namespace = await client.namespaces.delete('xxx');
* ```
*/
delete(name: string, options?: RequestOptions): APIPromise<NamespaceDeleteResponse> {
return this._client.delete(path`/namespaces/${name}`, options);
}
/**
* Create a new namespace owned by the authenticated user or an organization. This
* endpoint is idempotent - if the namespace already exists and is owned by the
* user/org, returns success. Pass organizationId in the request body to create an
* org-owned namespace.
*
* @example
* ```ts
* const response = await client.namespaces.set('xxx');
* ```
*/
set(name: string, options?: RequestOptions): APIPromise<NamespaceSetResponse> {
return this._client.put(path`/namespaces/${name}`, options);
}
}
export type NamespaceListResponsesNamespacesPage = NamespacesPage<NamespaceListResponse>;
export interface NamespaceCreateResponse {
createdAt: string;
name: string;
}
export interface NamespaceListResponse {
name: string;
}
export interface NamespaceDeleteResponse {
name: string;
success: boolean;
}
export interface NamespaceSetResponse {
createdAt: string;
name: string;
}
export interface NamespaceListParams extends NamespacesPageParams {
/**
* Comma-separated list of fields to include in response
*/
fields?: string;
/**
* Filter namespaces with servers
*/
hasServers?: '0' | '1' | 'true' | 'false';
/**
* Filter namespaces with skills
*/
hasSkills?: '0' | '1' | 'true' | 'false';
/**
* Filter by owner ID
*/
ownerId?: string;
/**
* Text search query (prefix match on name)
*/
q?: string;
}
Namespaces.Servers = Servers;
export declare namespace Namespaces {
export {
type NamespaceCreateResponse as NamespaceCreateResponse,
type NamespaceListResponse as NamespaceListResponse,
type NamespaceDeleteResponse as NamespaceDeleteResponse,
type NamespaceSetResponse as NamespaceSetResponse,
type NamespaceListResponsesNamespacesPage as NamespaceListResponsesNamespacesPage,
type NamespaceListParams as NamespaceListParams,
};
export {
Servers as Servers,
type ServerCreateResponse as ServerCreateResponse,
type ServerCreateParams as ServerCreateParams,
};
}