Skip to content

Commit f6fbb21

Browse files
feat(api): update via SDK Studio
1 parent f66c637 commit f6fbb21

11 files changed

Lines changed: 65 additions & 184 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 10
1+
configured_endpoints: 8
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/the-san-francisco-compute-company%2Fsfc-nodes-b800806859333bacc88fa4236eae35c8cdbec62970b7fb9ad440a330f24a1622.yml
33
openapi_spec_hash: fa672b6ca8953a8059961a7559a607a9
4-
config_hash: 499c74ded37140a0ec9c4acdafb8e634
4+
config_hash: e089259785c0c81187a2b25ae04b8459

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The full API of this library can be found in [api.md](api.md).
2626
import SFCNodes from 'sfc-nodes';
2727

2828
const client = new SFCNodes({
29-
bearerToken: process.env['SFC_BEARER_TOKEN'], // This is the default and can be omitted
29+
apiKey: process.env['SFC_API_KEY'], // This is the default and can be omitted
3030
});
3131

3232
const nodes = await client.nodes.list();
@@ -41,7 +41,7 @@ This library includes TypeScript definitions for all request params and response
4141
import SFCNodes from 'sfc-nodes';
4242

4343
const client = new SFCNodes({
44-
bearerToken: process.env['SFC_BEARER_TOKEN'], // This is the default and can be omitted
44+
apiKey: process.env['SFC_API_KEY'], // This is the default and can be omitted
4545
});
4646

4747
const nodes: SFCNodes.NodeListResponse = await client.nodes.list();

api.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
Types:
44

5-
- <code><a href="./src/resources/vms/vms.ts">VmListResponse</a></code>
65
- <code><a href="./src/resources/vms/vms.ts">VmLogsResponse</a></code>
7-
- <code><a href="./src/resources/vms/vms.ts">VmReplaceResponse</a></code>
86
- <code><a href="./src/resources/vms/vms.ts">VmSSHResponse</a></code>
97

108
Methods:
119

12-
- <code title="get /v0/vms/instances">client.vms.<a href="./src/resources/vms/vms.ts">list</a>() -> VmListResponse</code>
1310
- <code title="get /v0/vms/logs2">client.vms.<a href="./src/resources/vms/vms.ts">logs</a>({ ...params }) -> VmLogsResponse</code>
14-
- <code title="post /v0/vms/replace">client.vms.<a href="./src/resources/vms/vms.ts">replace</a>({ ...params }) -> VmReplaceResponse</code>
1511
- <code title="get /v0/vms/ssh">client.vms.<a href="./src/resources/vms/vms.ts">ssh</a>({ ...params }) -> VmSSHResponse</code>
1612

1713
## Script

src/client.ts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,7 @@ import {
2727
Nodes,
2828
UpdateNode,
2929
} from './resources/nodes';
30-
import {
31-
VmListResponse,
32-
VmLogsParams,
33-
VmLogsResponse,
34-
VmReplaceParams,
35-
VmReplaceResponse,
36-
VmSSHParams,
37-
VmSSHResponse,
38-
Vms,
39-
} from './resources/vms/vms';
30+
import { VmLogsParams, VmLogsResponse, VmSSHParams, VmSSHResponse, Vms } from './resources/vms/vms';
4031
import { type Fetch } from './internal/builtin-types';
4132
import { HeadersLike, NullableHeaders, buildHeaders } from './internal/headers';
4233
import { FinalRequestOptions, RequestOptions } from './internal/request-options';
@@ -52,9 +43,9 @@ import { isEmptyObj } from './internal/utils/values';
5243

5344
export interface ClientOptions {
5445
/**
55-
* Defaults to process.env['SFC_BEARER_TOKEN'].
46+
* Defaults to process.env['SFC_API_KEY'].
5647
*/
57-
bearerToken?: string | null | undefined;
48+
apiKey?: string | null | undefined;
5849

5950
/**
6051
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
@@ -129,7 +120,7 @@ export interface ClientOptions {
129120
* API Client for interfacing with the SFC Nodes API.
130121
*/
131122
export class SFCNodes {
132-
bearerToken: string | null;
123+
apiKey: string | null;
133124

134125
baseURL: string;
135126
maxRetries: number;
@@ -146,7 +137,7 @@ export class SFCNodes {
146137
/**
147138
* API Client for interfacing with the SFC Nodes API.
148139
*
149-
* @param {string | null | undefined} [opts.bearerToken=process.env['SFC_BEARER_TOKEN'] ?? null]
140+
* @param {string | null | undefined} [opts.apiKey=process.env['SFC_API_KEY'] ?? null]
150141
* @param {string} [opts.baseURL=process.env['SFC_NODES_BASE_URL'] ?? https://api.sfcompute.com] - Override the default base URL for the API.
151142
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
152143
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -157,11 +148,11 @@ export class SFCNodes {
157148
*/
158149
constructor({
159150
baseURL = readEnv('SFC_NODES_BASE_URL'),
160-
bearerToken = readEnv('SFC_BEARER_TOKEN') ?? null,
151+
apiKey = readEnv('SFC_API_KEY') ?? null,
161152
...opts
162153
}: ClientOptions = {}) {
163154
const options: ClientOptions = {
164-
bearerToken,
155+
apiKey,
165156
...opts,
166157
baseURL: baseURL || `https://api.sfcompute.com`,
167158
};
@@ -183,7 +174,7 @@ export class SFCNodes {
183174

184175
this._options = options;
185176

186-
this.bearerToken = bearerToken;
177+
this.apiKey = apiKey;
187178
}
188179

189180
/**
@@ -199,7 +190,7 @@ export class SFCNodes {
199190
logLevel: this.logLevel,
200191
fetch: this.fetch,
201192
fetchOptions: this.fetchOptions,
202-
bearerToken: this.bearerToken,
193+
apiKey: this.apiKey,
203194
...options,
204195
});
205196
return client;
@@ -217,23 +208,23 @@ export class SFCNodes {
217208
}
218209

219210
protected validateHeaders({ values, nulls }: NullableHeaders) {
220-
if (this.bearerToken && values.get('authorization')) {
211+
if (this.apiKey && values.get('authorization')) {
221212
return;
222213
}
223214
if (nulls.has('authorization')) {
224215
return;
225216
}
226217

227218
throw new Error(
228-
'Could not resolve authentication method. Expected the bearerToken to be set. Or for the "Authorization" headers to be explicitly omitted',
219+
'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted',
229220
);
230221
}
231222

232223
protected async authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined> {
233-
if (this.bearerToken == null) {
224+
if (this.apiKey == null) {
234225
return undefined;
235226
}
236-
return buildHeaders([{ Authorization: `Bearer ${this.bearerToken}` }]);
227+
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
237228
}
238229

239230
/**
@@ -750,12 +741,9 @@ export declare namespace SFCNodes {
750741

751742
export {
752743
Vms as Vms,
753-
type VmListResponse as VmListResponse,
754744
type VmLogsResponse as VmLogsResponse,
755-
type VmReplaceResponse as VmReplaceResponse,
756745
type VmSSHResponse as VmSSHResponse,
757746
type VmLogsParams as VmLogsParams,
758-
type VmReplaceParams as VmReplaceParams,
759747
type VmSSHParams as VmSSHParams,
760748
};
761749

src/resources/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,4 @@ export {
1111
type NodeExtendParams,
1212
type NodeReleaseParams,
1313
} from './nodes';
14-
export {
15-
Vms,
16-
type VmListResponse,
17-
type VmLogsResponse,
18-
type VmReplaceResponse,
19-
type VmSSHResponse,
20-
type VmLogsParams,
21-
type VmReplaceParams,
22-
type VmSSHParams,
23-
} from './vms/vms';
14+
export { Vms, type VmLogsResponse, type VmSSHResponse, type VmLogsParams, type VmSSHParams } from './vms/vms';

src/resources/vms/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,4 @@ export {
77
type ScriptRetrieveResponse,
88
type ScriptCreateParams,
99
} from './script';
10-
export {
11-
Vms,
12-
type VmListResponse,
13-
type VmLogsResponse,
14-
type VmReplaceResponse,
15-
type VmSSHResponse,
16-
type VmLogsParams,
17-
type VmReplaceParams,
18-
type VmSSHParams,
19-
} from './vms';
10+
export { Vms, type VmLogsResponse, type VmSSHResponse, type VmLogsParams, type VmSSHParams } from './vms';

src/resources/vms/vms.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,15 @@ import { RequestOptions } from '../../internal/request-options';
99
export class Vms extends APIResource {
1010
script: ScriptAPI.Script = new ScriptAPI.Script(this._client);
1111

12-
list(options?: RequestOptions): APIPromise<VmListResponse> {
13-
return this._client.get('/v0/vms/instances', options);
14-
}
15-
1612
logs(query: VmLogsParams, options?: RequestOptions): APIPromise<VmLogsResponse> {
1713
return this._client.get('/v0/vms/logs2', { query, ...options });
1814
}
1915

20-
replace(body: VmReplaceParams, options?: RequestOptions): APIPromise<VmReplaceResponse> {
21-
return this._client.post('/v0/vms/replace', { body, ...options });
22-
}
23-
2416
ssh(query: VmSSHParams, options?: RequestOptions): APIPromise<VmSSHResponse> {
2517
return this._client.get('/v0/vms/ssh', { query, ...options });
2618
}
2719
}
2820

29-
export interface VmListResponse {
30-
data: Array<VmListResponse.Data>;
31-
}
32-
33-
export namespace VmListResponse {
34-
export interface Data {
35-
id: string;
36-
37-
cluster_id: string;
38-
39-
current_status: string;
40-
41-
instance_group_id: string;
42-
43-
last_updated_at: string;
44-
}
45-
}
46-
4721
export interface VmLogsResponse {
4822
data: Array<VmLogsResponse.Data>;
4923
}
@@ -67,12 +41,6 @@ export namespace VmLogsResponse {
6741
}
6842
}
6943

70-
export interface VmReplaceResponse {
71-
replaced: string;
72-
73-
replaced_by: string;
74-
}
75-
7644
export interface VmSSHResponse {
7745
ssh_hostname: string;
7846

@@ -105,10 +73,6 @@ export interface VmLogsParams {
10573
since_seqnum?: number;
10674
}
10775

108-
export interface VmReplaceParams {
109-
vm_id: string;
110-
}
111-
11276
export interface VmSSHParams {
11377
vm_id: string;
11478
}
@@ -117,12 +81,9 @@ Vms.Script = Script;
11781

11882
export declare namespace Vms {
11983
export {
120-
type VmListResponse as VmListResponse,
12184
type VmLogsResponse as VmLogsResponse,
122-
type VmReplaceResponse as VmReplaceResponse,
12385
type VmSSHResponse as VmSSHResponse,
12486
type VmLogsParams as VmLogsParams,
125-
type VmReplaceParams as VmReplaceParams,
12687
type VmSSHParams as VmSSHParams,
12788
};
12889

tests/api-resources/nodes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import SFCNodes from 'sfc-nodes';
44

55
const client = new SFCNodes({
6-
bearerToken: 'My Bearer Token',
6+
apiKey: 'My API Key',
77
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
88
});
99

tests/api-resources/vms/script.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import SFCNodes from 'sfc-nodes';
44

55
const client = new SFCNodes({
6-
bearerToken: 'My Bearer Token',
6+
apiKey: 'My API Key',
77
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
88
});
99

tests/api-resources/vms/vms.test.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,11 @@
33
import SFCNodes from 'sfc-nodes';
44

55
const client = new SFCNodes({
6-
bearerToken: 'My Bearer Token',
6+
apiKey: 'My API Key',
77
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
88
});
99

1010
describe('resource vms', () => {
11-
// skipped: tests are disabled for the time being
12-
test.skip('list', async () => {
13-
const responsePromise = client.vms.list();
14-
const rawResponse = await responsePromise.asResponse();
15-
expect(rawResponse).toBeInstanceOf(Response);
16-
const response = await responsePromise;
17-
expect(response).not.toBeInstanceOf(Response);
18-
const dataAndResponse = await responsePromise.withResponse();
19-
expect(dataAndResponse.data).toBe(response);
20-
expect(dataAndResponse.response).toBe(rawResponse);
21-
});
22-
2311
// skipped: tests are disabled for the time being
2412
test.skip('logs: only required params', async () => {
2513
const responsePromise = client.vms.logs({ instance_id: 'instance_id', order_by: 'seqnum_asc' });
@@ -45,23 +33,6 @@ describe('resource vms', () => {
4533
});
4634
});
4735

48-
// skipped: tests are disabled for the time being
49-
test.skip('replace: only required params', async () => {
50-
const responsePromise = client.vms.replace({ vm_id: 'vm_id' });
51-
const rawResponse = await responsePromise.asResponse();
52-
expect(rawResponse).toBeInstanceOf(Response);
53-
const response = await responsePromise;
54-
expect(response).not.toBeInstanceOf(Response);
55-
const dataAndResponse = await responsePromise.withResponse();
56-
expect(dataAndResponse.data).toBe(response);
57-
expect(dataAndResponse.response).toBe(rawResponse);
58-
});
59-
60-
// skipped: tests are disabled for the time being
61-
test.skip('replace: required and optional params', async () => {
62-
const response = await client.vms.replace({ vm_id: 'vm_id' });
63-
});
64-
6536
// skipped: tests are disabled for the time being
6637
test.skip('ssh: only required params', async () => {
6738
const responsePromise = client.vms.ssh({ vm_id: 'vm_id' });

0 commit comments

Comments
 (0)