Skip to content

Commit 68ab468

Browse files
committed
feat(tenants): add Tenants resource
1 parent 3395404 commit 68ab468

13 files changed

Lines changed: 570 additions & 0 deletions

File tree

src/resources/tenants.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 './tenants/index';
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 { APIResource } from '../../resource';
4+
import * as Core from '../../core';
5+
import { SinglePage } from '../../pagination';
6+
7+
export class AccountTypes extends APIResource {
8+
/**
9+
* List of account types available for the Tenant to provision accounts.
10+
*/
11+
list(
12+
tenantId: string,
13+
options?: Core.RequestOptions,
14+
): Core.PagePromise<AccountTypeListResponsesSinglePage, AccountTypeListResponse> {
15+
return this._client.getAPIList(
16+
`/tenants/${tenantId}/account_types`,
17+
AccountTypeListResponsesSinglePage,
18+
options,
19+
);
20+
}
21+
}
22+
23+
export class AccountTypeListResponsesSinglePage extends SinglePage<AccountTypeListResponse> {}
24+
25+
export type AccountTypeListResponse = string;
26+
27+
AccountTypes.AccountTypeListResponsesSinglePage = AccountTypeListResponsesSinglePage;
28+
29+
export declare namespace AccountTypes {
30+
export {
31+
type AccountTypeListResponse as AccountTypeListResponse,
32+
AccountTypeListResponsesSinglePage as AccountTypeListResponsesSinglePage,
33+
};
34+
}

src/resources/tenants/accounts.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../resource';
4+
import * as Core from '../../core';
5+
import { SinglePage } from '../../pagination';
6+
7+
export class Accounts extends APIResource {
8+
/**
9+
* List of accounts for the Tenant.
10+
*/
11+
list(
12+
tenantId: string,
13+
options?: Core.RequestOptions,
14+
): Core.PagePromise<TenantAccountsSinglePage, TenantAccount> {
15+
return this._client.getAPIList(`/tenants/${tenantId}/accounts`, TenantAccountsSinglePage, options);
16+
}
17+
}
18+
19+
export class TenantAccountsSinglePage extends SinglePage<TenantAccount> {}
20+
21+
export interface TenantAccount {
22+
id: string;
23+
24+
created_on: string;
25+
26+
name: string | null;
27+
28+
settings: TenantAccount.Settings;
29+
30+
type: 'standard' | 'enterprise';
31+
}
32+
33+
export namespace TenantAccount {
34+
export interface Settings {
35+
abuse_contact_email: string | null;
36+
37+
access_approval_expiry: string | null;
38+
39+
api_access_enabled: boolean | null;
40+
41+
/**
42+
* @deprecated Use
43+
* [DNS Settings](https://developers.cloudflare.com/api/operations/dns-settings-for-an-account-list-dns-settings)
44+
* instead. Deprecated.
45+
*/
46+
default_nameservers: string | null;
47+
48+
enforce_twofactor: boolean | null;
49+
50+
/**
51+
* @deprecated Use
52+
* [DNS Settings](https://developers.cloudflare.com/api/operations/dns-settings-for-an-account-list-dns-settings)
53+
* instead. Deprecated.
54+
*/
55+
use_account_custom_ns_by_default: boolean | null;
56+
}
57+
}
58+
59+
Accounts.TenantAccountsSinglePage = TenantAccountsSinglePage;
60+
61+
export declare namespace Accounts {
62+
export { type TenantAccount as TenantAccount, TenantAccountsSinglePage as TenantAccountsSinglePage };
63+
}

src/resources/tenants/api.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Tenants
2+
3+
Types:
4+
5+
- <code><a href="./src/resources/tenants/tenants.ts">Tenant</a></code>
6+
7+
Methods:
8+
9+
- <code title="get /tenants/{tenant_id}">client.tenants.<a href="./src/resources/tenants/tenants.ts">get</a>(tenantId) -> Tenant</code>
10+
11+
## AccountTypes
12+
13+
Types:
14+
15+
- <code><a href="./src/resources/tenants/account-types.ts">AccountTypeListResponse</a></code>
16+
17+
Methods:
18+
19+
- <code title="get /tenants/{tenant_id}/account_types">client.tenants.accountTypes.<a href="./src/resources/tenants/account-types.ts">list</a>(tenantId) -> AccountTypeListResponsesSinglePage</code>
20+
21+
## Accounts
22+
23+
Types:
24+
25+
- <code><a href="./src/resources/tenants/accounts.ts">TenantAccount</a></code>
26+
27+
Methods:
28+
29+
- <code title="get /tenants/{tenant_id}/accounts">client.tenants.accounts.<a href="./src/resources/tenants/accounts.ts">list</a>(tenantId) -> TenantAccountsSinglePage</code>
30+
31+
## Entitlements
32+
33+
Types:
34+
35+
- <code><a href="./src/resources/tenants/entitlements.ts">TenantEntitlements</a></code>
36+
37+
Methods:
38+
39+
- <code title="get /tenants/{tenant_id}/entitlements">client.tenants.entitlements.<a href="./src/resources/tenants/entitlements.ts">get</a>(tenantId) -> TenantEntitlements</code>
40+
41+
## Memberships
42+
43+
Types:
44+
45+
- <code><a href="./src/resources/tenants/memberships.ts">TenantMembership</a></code>
46+
47+
Methods:
48+
49+
- <code title="get /tenants/{tenant_id}/memberships">client.tenants.memberships.<a href="./src/resources/tenants/memberships.ts">list</a>(tenantId) -> TenantMembershipsSinglePage</code>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../resource';
4+
import * as Core from '../../core';
5+
6+
export class Entitlements extends APIResource {
7+
/**
8+
* List of innate entitlements available for the Tenant.
9+
*/
10+
get(tenantId: string, options?: Core.RequestOptions): Core.APIPromise<TenantEntitlements> {
11+
return (
12+
this._client.get(`/tenants/${tenantId}/entitlements`, options) as Core.APIPromise<{
13+
result: TenantEntitlements;
14+
}>
15+
)._thenUnwrap((obj) => obj.result);
16+
}
17+
}
18+
19+
export interface TenantEntitlements {
20+
allow_add_subdomain: TenantEntitlements.AllowAddSubdomain;
21+
22+
allow_auto_accept_invites: TenantEntitlements.AllowAutoAcceptInvites;
23+
24+
cname_setup_allowed: TenantEntitlements.CNAMESetupAllowed;
25+
26+
custom_entitlements: Array<TenantEntitlements.CustomEntitlement> | null;
27+
28+
mhs_certificate_count: TenantEntitlements.MhsCertificateCount;
29+
30+
partial_setup_allowed: TenantEntitlements.PartialSetupAllowed;
31+
}
32+
33+
export namespace TenantEntitlements {
34+
export interface AllowAddSubdomain {
35+
type: 'bool';
36+
37+
value: boolean;
38+
}
39+
40+
export interface AllowAutoAcceptInvites {
41+
type: 'bool';
42+
43+
value: boolean;
44+
}
45+
46+
export interface CNAMESetupAllowed {
47+
type: 'bool';
48+
49+
value: boolean;
50+
}
51+
52+
export interface CustomEntitlement {
53+
allocation:
54+
| CustomEntitlement.OrganizationsAPIMaxCountAllocation
55+
| CustomEntitlement.OrganizationsAPIBoolAllocation
56+
| CustomEntitlement.OrganizationsAPINullAllocation;
57+
58+
feature: CustomEntitlement.Feature;
59+
}
60+
61+
export namespace CustomEntitlement {
62+
export interface OrganizationsAPIMaxCountAllocation {
63+
type: 'max_count';
64+
65+
value: number;
66+
}
67+
68+
export interface OrganizationsAPIBoolAllocation {
69+
type: 'bool';
70+
71+
value: boolean;
72+
}
73+
74+
export interface OrganizationsAPINullAllocation {
75+
type: '';
76+
77+
value?: unknown;
78+
}
79+
80+
export interface Feature {
81+
key: string;
82+
}
83+
}
84+
85+
export interface MhsCertificateCount {
86+
type: 'max_count';
87+
88+
value: number;
89+
}
90+
91+
export interface PartialSetupAllowed {
92+
type: 'bool';
93+
94+
value: boolean;
95+
}
96+
}
97+
98+
export declare namespace Entitlements {
99+
export { type TenantEntitlements as TenantEntitlements };
100+
}

src/resources/tenants/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export {
4+
AccountTypeListResponsesSinglePage,
5+
AccountTypes,
6+
type AccountTypeListResponse,
7+
} from './account-types';
8+
export { Entitlements, type TenantEntitlements } from './entitlements';
9+
export { TenantAccountsSinglePage, Accounts, type TenantAccount } from './accounts';
10+
export { TenantMembershipsSinglePage, Memberships, type TenantMembership } from './memberships';
11+
export { Tenants } from './tenants';
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../resource';
4+
import * as Core from '../../core';
5+
import { SinglePage } from '../../pagination';
6+
7+
export class Memberships extends APIResource {
8+
/**
9+
* List of active members (Cloudflare users) for the Tenant.
10+
*/
11+
list(
12+
tenantId: string,
13+
options?: Core.RequestOptions,
14+
): Core.PagePromise<TenantMembershipsSinglePage, TenantMembership> {
15+
return this._client.getAPIList(`/tenants/${tenantId}/memberships`, TenantMembershipsSinglePage, options);
16+
}
17+
}
18+
19+
export class TenantMembershipsSinglePage extends SinglePage<TenantMembership> {}
20+
21+
export interface TenantMembership {
22+
user_email: string;
23+
24+
user_name: string;
25+
26+
user_tag: string;
27+
}
28+
29+
Memberships.TenantMembershipsSinglePage = TenantMembershipsSinglePage;
30+
31+
export declare namespace Memberships {
32+
export {
33+
type TenantMembership as TenantMembership,
34+
TenantMembershipsSinglePage as TenantMembershipsSinglePage,
35+
};
36+
}

0 commit comments

Comments
 (0)