Skip to content

Commit b5aa208

Browse files
feat: Add org-level default per-project concurrency cap
1 parent 2a7ed1f commit b5aa208

9 files changed

Lines changed: 156 additions & 4 deletions

File tree

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 117
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-08c2d6a44f4cdcbfb6803a3043fdc1a3e33911dec4652cb3a870f01bc584421f.yml
3-
openapi_spec_hash: c816491451347eb93b793cddf6a78648
4-
config_hash: 9e45c27425021d49b5391f5cc980b046
1+
configured_endpoints: 119
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-76f6c461ca9fd01958f3315a4f5d558ef80896c8aa0496e38caef55d4bd51dbd.yml
3+
openapi_spec_hash: bb8124b6016b73022c52e6ef5b7220a4
4+
config_hash: 80eef1b592110714ea55cd26c470fabb

api.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,20 @@ Methods:
375375
- <code title="get /org/projects/{id}/limits">client.projects.limits.<a href="./src/resources/projects/limits.ts">retrieve</a>(id) -> ProjectLimits</code>
376376
- <code title="patch /org/projects/{id}/limits">client.projects.limits.<a href="./src/resources/projects/limits.ts">update</a>(id, { ...params }) -> ProjectLimits</code>
377377

378+
# Organization
379+
380+
## Limits
381+
382+
Types:
383+
384+
- <code><a href="./src/resources/organization/limits.ts">OrgLimits</a></code>
385+
- <code><a href="./src/resources/organization/limits.ts">UpdateOrgLimitsRequest</a></code>
386+
387+
Methods:
388+
389+
- <code title="get /org/limits">client.organization.limits.<a href="./src/resources/organization/limits.ts">retrieve</a>() -> OrgLimits</code>
390+
- <code title="patch /org/limits">client.organization.limits.<a href="./src/resources/organization/limits.ts">update</a>({ ...params }) -> OrgLimits</code>
391+
378392
# APIKeys
379393

380394
Types:

src/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ import {
139139
Profile,
140140
Tags,
141141
} from './resources/browsers/browsers';
142+
import { Organization } from './resources/organization/organization';
142143
import {
143144
CreateProjectRequest,
144145
Project,
@@ -983,6 +984,7 @@ export class Kernel {
983984
* Create and manage projects for resource isolation within an organization.
984985
*/
985986
projects: API.Projects = new API.Projects(this);
987+
organization: API.Organization = new API.Organization(this);
986988
/**
987989
* Create and manage API keys for organization and project-scoped access.
988990
*/
@@ -1004,6 +1006,7 @@ Kernel.Extensions = Extensions;
10041006
Kernel.BrowserPools = BrowserPools;
10051007
Kernel.Credentials = Credentials;
10061008
Kernel.Projects = Projects;
1009+
Kernel.Organization = Organization;
10071010
Kernel.APIKeys = APIKeys;
10081011
Kernel.CredentialProviders = CredentialProviders;
10091012

@@ -1138,6 +1141,8 @@ export declare namespace Kernel {
11381141
type ProjectListParams as ProjectListParams,
11391142
};
11401143

1144+
export { Organization as Organization };
1145+
11411146
export {
11421147
APIKeys as APIKeys,
11431148
type APIKey as APIKey,

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export {
109109
type InvocationFollowParams,
110110
type InvocationListResponsesOffsetPagination,
111111
} from './invocations';
112+
export { Organization } from './organization/organization';
112113
export { Profiles, type ProfileCreateParams, type ProfileListParams } from './profiles';
113114
export {
114115
Projects,

src/resources/organization.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export * from './organization/index';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export { Limits, type OrgLimits, type UpdateOrgLimitsRequest, type LimitUpdateParams } from './limits';
4+
export { Organization } from './organization';
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../core/resource';
4+
import { APIPromise } from '../../core/api-promise';
5+
import { RequestOptions } from '../../internal/request-options';
6+
7+
/**
8+
* Read and manage organization-level limits.
9+
*/
10+
export class Limits extends APIResource {
11+
/**
12+
* Get the organization's concurrent session ceiling and the default per-project
13+
* concurrency cap applied to projects without an explicit override.
14+
*/
15+
retrieve(options?: RequestOptions): APIPromise<OrgLimits> {
16+
return this._client.get('/org/limits', options);
17+
}
18+
19+
/**
20+
* Set the default per-project concurrency cap applied to projects without an
21+
* explicit override. Set the value to 0 to remove the default; omit to leave it
22+
* unchanged. The default cannot exceed the organization's concurrent session
23+
* ceiling.
24+
*/
25+
update(body: LimitUpdateParams, options?: RequestOptions): APIPromise<OrgLimits> {
26+
return this._client.patch('/org/limits', { body, ...options });
27+
}
28+
}
29+
30+
export interface OrgLimits {
31+
/**
32+
* Default maximum concurrent browser sessions applied to every project that has no
33+
* explicit per-project override. Null means no org-level default, so such projects
34+
* are uncapped (only the org-wide limit applies). Applies to existing and newly
35+
* created projects.
36+
*/
37+
default_project_max_concurrent_sessions?: number | null;
38+
39+
/**
40+
* The organization's effective concurrent browser session ceiling, from its plan
41+
* or an override. Read-only and shared across all projects in the org; a
42+
* per-project default cannot exceed it.
43+
*/
44+
max_concurrent_sessions?: number;
45+
}
46+
47+
export interface UpdateOrgLimitsRequest {
48+
/**
49+
* Default maximum concurrent browser sessions for projects without an explicit
50+
* override. Set to 0 to remove the default; omit to leave unchanged. Cannot exceed
51+
* the organization's concurrent session ceiling.
52+
*/
53+
default_project_max_concurrent_sessions?: number | null;
54+
}
55+
56+
export interface LimitUpdateParams {
57+
/**
58+
* Default maximum concurrent browser sessions for projects without an explicit
59+
* override. Set to 0 to remove the default; omit to leave unchanged. Cannot exceed
60+
* the organization's concurrent session ceiling.
61+
*/
62+
default_project_max_concurrent_sessions?: number | null;
63+
}
64+
65+
export declare namespace Limits {
66+
export {
67+
type OrgLimits as OrgLimits,
68+
type UpdateOrgLimitsRequest as UpdateOrgLimitsRequest,
69+
type LimitUpdateParams as LimitUpdateParams,
70+
};
71+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../core/resource';
4+
import * as LimitsAPI from './limits';
5+
import { LimitUpdateParams, Limits, OrgLimits, UpdateOrgLimitsRequest } from './limits';
6+
7+
export class Organization extends APIResource {
8+
limits: LimitsAPI.Limits = new LimitsAPI.Limits(this._client);
9+
}
10+
11+
Organization.Limits = Limits;
12+
13+
export declare namespace Organization {
14+
export {
15+
Limits as Limits,
16+
type OrgLimits as OrgLimits,
17+
type UpdateOrgLimitsRequest as UpdateOrgLimitsRequest,
18+
type LimitUpdateParams as LimitUpdateParams,
19+
};
20+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Kernel from '@onkernel/sdk';
4+
5+
const client = new Kernel({
6+
apiKey: 'My API Key',
7+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8+
});
9+
10+
describe('resource limits', () => {
11+
// Mock server tests are disabled
12+
test.skip('retrieve', async () => {
13+
const responsePromise = client.organization.limits.retrieve();
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+
23+
// Mock server tests are disabled
24+
test.skip('update', async () => {
25+
const responsePromise = client.organization.limits.update({});
26+
const rawResponse = await responsePromise.asResponse();
27+
expect(rawResponse).toBeInstanceOf(Response);
28+
const response = await responsePromise;
29+
expect(response).not.toBeInstanceOf(Response);
30+
const dataAndResponse = await responsePromise.withResponse();
31+
expect(dataAndResponse.data).toBe(response);
32+
expect(dataAndResponse.response).toBe(rawResponse);
33+
});
34+
});

0 commit comments

Comments
 (0)