-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathingresses.ts
More file actions
192 lines (168 loc) · 4.29 KB
/
ingresses.ts
File metadata and controls
192 lines (168 loc) · 4.29 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { buildHeaders } from '../internal/headers';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
export class Ingresses extends APIResource {
/**
* Create ingress
*
* @example
* ```ts
* const ingress = await client.ingresses.create({
* name: 'my-api-ingress',
* rules: [
* {
* match: { hostname: '{instance}.example.com' },
* target: { instance: '{instance}', port: 8080 },
* },
* ],
* });
* ```
*/
create(body: IngressCreateParams, options?: RequestOptions): APIPromise<Ingress> {
return this._client.post('/ingresses', { body, ...options });
}
/**
* List ingresses
*
* @example
* ```ts
* const ingresses = await client.ingresses.list();
* ```
*/
list(
query: IngressListParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<IngressListResponse> {
return this._client.get('/ingresses', { query, ...options });
}
/**
* Delete ingress
*
* @example
* ```ts
* await client.ingresses.delete('id');
* ```
*/
delete(id: string, options?: RequestOptions): APIPromise<void> {
return this._client.delete(path`/ingresses/${id}`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
/**
* Get ingress details
*
* @example
* ```ts
* const ingress = await client.ingresses.get('id');
* ```
*/
get(id: string, options?: RequestOptions): APIPromise<Ingress> {
return this._client.get(path`/ingresses/${id}`, options);
}
}
export interface Ingress {
/**
* Auto-generated unique identifier
*/
id: string;
/**
* Creation timestamp (RFC3339)
*/
created_at: string;
/**
* Human-readable name
*/
name: string;
/**
* Routing rules for this ingress
*/
rules: Array<IngressRule>;
/**
* User-defined key-value tags.
*/
tags?: { [key: string]: string };
}
export interface IngressMatch {
/**
* Hostname to match. Can be:
*
* - Literal: "api.example.com" (exact match on Host header)
* - Pattern: "{instance}.example.com" (dynamic routing based on subdomain)
*
* Pattern hostnames use named captures in curly braces (e.g., {instance}, {app})
* that extract parts of the hostname for routing. The extracted values can be
* referenced in the target.instance field.
*/
hostname: string;
/**
* Host port to listen on for this rule (default 80)
*/
port?: number;
}
export interface IngressRule {
match: IngressMatch;
target: IngressTarget;
/**
* Auto-create HTTP to HTTPS redirect for this hostname (only applies when tls is
* enabled)
*/
redirect_http?: boolean;
/**
* Enable TLS termination (certificate auto-issued via ACME).
*/
tls?: boolean;
}
export interface IngressTarget {
/**
* Target instance name, ID, or capture reference.
*
* - For literal hostnames: Use the instance name or ID directly (e.g., "my-api")
* - For pattern hostnames: Reference a capture from the hostname (e.g.,
* "{instance}")
*
* When using pattern hostnames, the instance is resolved dynamically at request
* time.
*/
instance: string;
/**
* Target port on the instance
*/
port: number;
}
export type IngressListResponse = Array<Ingress>;
export interface IngressCreateParams {
/**
* Human-readable name (lowercase letters, digits, and dashes only; cannot start or
* end with a dash)
*/
name: string;
/**
* Routing rules for this ingress
*/
rules: Array<IngressRule>;
/**
* User-defined key-value tags.
*/
tags?: { [key: string]: string };
}
export interface IngressListParams {
/**
* Filter ingresses by tag key-value pairs.
*/
tags?: { [key: string]: string };
}
export declare namespace Ingresses {
export {
type Ingress as Ingress,
type IngressMatch as IngressMatch,
type IngressRule as IngressRule,
type IngressTarget as IngressTarget,
type IngressListResponse as IngressListResponse,
type IngressCreateParams as IngressCreateParams,
type IngressListParams as IngressListParams,
};
}