Skip to content

Commit f10edca

Browse files
feat(access_settings): add CRUD support
1 parent a46f4f1 commit f10edca

File tree

6 files changed

+234
-2
lines changed

6 files changed

+234
-2
lines changed

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1711
1+
configured_endpoints: 1713
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ecd33718055a881f934a11ead007f2b0cfc65df9bae35bf1616e3a3c32bd6705.yml
33
openapi_spec_hash: e863852213e01c0f1e48d9557a2888d8
4-
config_hash: 161785081308d4246057a8723ae7d7e2
4+
config_hash: 4a6de620bf46745e17466ceac26f41d4

api.md

+12
Original file line numberDiff line numberDiff line change
@@ -5025,6 +5025,18 @@ Methods:
50255025

50265026
- <code title="get /accounts/{account_id}/access/policy-tests/{policy_test_id}/users">client.zeroTrust.access.applications.policyTests.users.<a href="./src/resources/zero-trust/access/applications/policy-tests/users.ts">list</a>(policyTestId, { ...params }) -> UserListResponsesV4PagePaginationArray</code>
50275027

5028+
#### Settings
5029+
5030+
Types:
5031+
5032+
- <code><a href="./src/resources/zero-trust/access/applications/settings.ts">SettingUpdateResponse</a></code>
5033+
- <code><a href="./src/resources/zero-trust/access/applications/settings.ts">SettingEditResponse</a></code>
5034+
5035+
Methods:
5036+
5037+
- <code title="put /{accounts_or_zones}/{account_or_zone_id}/access/apps/{app_id}/settings">client.zeroTrust.access.applications.settings.<a href="./src/resources/zero-trust/access/applications/settings.ts">update</a>(appId, { ...params }) -> SettingUpdateResponse</code>
5038+
- <code title="patch /{accounts_or_zones}/{account_or_zone_id}/access/apps/{app_id}/settings">client.zeroTrust.access.applications.settings.<a href="./src/resources/zero-trust/access/applications/settings.ts">edit</a>(appId, { ...params }) -> SettingEditResponse</code>
5039+
50285040
### Certificates
50295041

50305042
Types:

src/resources/zero-trust/access/applications/applications.ts

+18
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ import {
5151
SAMLGroupRule,
5252
ServiceTokenRule,
5353
} from './policies';
54+
import * as SettingsAPI from './settings';
55+
import {
56+
SettingEditParams,
57+
SettingEditResponse,
58+
SettingUpdateParams,
59+
SettingUpdateResponse,
60+
Settings,
61+
} from './settings';
5462
import * as UserPolicyChecksAPI from './user-policy-checks';
5563
import {
5664
UserPolicyCheckGeo,
@@ -76,6 +84,7 @@ export class Applications extends APIResource {
7684
);
7785
policies: ApplicationsPoliciesAPI.Policies = new ApplicationsPoliciesAPI.Policies(this._client);
7886
policyTests: PolicyTestsAPI.PolicyTests = new PolicyTestsAPI.PolicyTests(this._client);
87+
settings: SettingsAPI.Settings = new SettingsAPI.Settings(this._client);
7988

8089
/**
8190
* Adds a new application to Access.
@@ -21704,6 +21713,7 @@ Applications.UserPolicyChecks = UserPolicyChecks;
2170421713
Applications.Policies = Policies;
2170521714
Applications.PolicyListResponsesSinglePage = PolicyListResponsesSinglePage;
2170621715
Applications.PolicyTests = PolicyTests;
21716+
Applications.Settings = Settings;
2170721717

2170821718
export declare namespace Applications {
2170921719
export {
@@ -21801,4 +21811,12 @@ export declare namespace Applications {
2180121811
type PolicyTestCreateParams as PolicyTestCreateParams,
2180221812
type PolicyTestGetParams as PolicyTestGetParams,
2180321813
};
21814+
21815+
export {
21816+
Settings as Settings,
21817+
type SettingUpdateResponse as SettingUpdateResponse,
21818+
type SettingEditResponse as SettingEditResponse,
21819+
type SettingUpdateParams as SettingUpdateParams,
21820+
type SettingEditParams as SettingEditParams,
21821+
};
2180421822
}

src/resources/zero-trust/access/applications/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ export {
8686
type PolicyTestCreateParams,
8787
type PolicyTestGetParams,
8888
} from './policy-tests/index';
89+
export {
90+
Settings,
91+
type SettingUpdateResponse,
92+
type SettingEditResponse,
93+
type SettingUpdateParams,
94+
type SettingEditParams,
95+
} from './settings';
8996
export {
9097
UserPolicyChecks,
9198
type UserPolicyCheckGeo,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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 * as ApplicationsAPI from './applications';
6+
import { CloudflareError } from '../../../../error';
7+
8+
export class Settings extends APIResource {
9+
/**
10+
* Updates Access application settings.
11+
*/
12+
update(
13+
appId: ApplicationsAPI.AppIDParam,
14+
params: SettingUpdateParams,
15+
options?: Core.RequestOptions,
16+
): Core.APIPromise<SettingUpdateResponse> {
17+
const { account_id, zone_id, ...body } = params;
18+
if (!account_id && !zone_id) {
19+
throw new CloudflareError('You must provide either account_id or zone_id.');
20+
}
21+
if (account_id && zone_id) {
22+
throw new CloudflareError('You cannot provide both account_id and zone_id.');
23+
}
24+
const { accountOrZone, accountOrZoneId } =
25+
account_id ?
26+
{
27+
accountOrZone: 'accounts',
28+
accountOrZoneId: account_id,
29+
}
30+
: {
31+
accountOrZone: 'zones',
32+
accountOrZoneId: zone_id,
33+
};
34+
return (
35+
this._client.put(`/${accountOrZone}/${accountOrZoneId}/access/apps/${appId}/settings`, {
36+
body,
37+
...options,
38+
}) as Core.APIPromise<{ result: SettingUpdateResponse }>
39+
)._thenUnwrap((obj) => obj.result);
40+
}
41+
42+
/**
43+
* Updates Access application settings.
44+
*/
45+
edit(
46+
appId: ApplicationsAPI.AppIDParam,
47+
params: SettingEditParams,
48+
options?: Core.RequestOptions,
49+
): Core.APIPromise<SettingEditResponse> {
50+
const { account_id, zone_id, ...body } = params;
51+
if (!account_id && !zone_id) {
52+
throw new CloudflareError('You must provide either account_id or zone_id.');
53+
}
54+
if (account_id && zone_id) {
55+
throw new CloudflareError('You cannot provide both account_id and zone_id.');
56+
}
57+
const { accountOrZone, accountOrZoneId } =
58+
account_id ?
59+
{
60+
accountOrZone: 'accounts',
61+
accountOrZoneId: account_id,
62+
}
63+
: {
64+
accountOrZone: 'zones',
65+
accountOrZoneId: zone_id,
66+
};
67+
return (
68+
this._client.patch(`/${accountOrZone}/${accountOrZoneId}/access/apps/${appId}/settings`, {
69+
body,
70+
...options,
71+
}) as Core.APIPromise<{ result: SettingEditResponse }>
72+
)._thenUnwrap((obj) => obj.result);
73+
}
74+
}
75+
76+
export interface SettingUpdateResponse {
77+
/**
78+
* Enables loading application content in an iFrame.
79+
*/
80+
allow_iframe?: boolean;
81+
82+
/**
83+
* Enables automatic authentication through cloudflared.
84+
*/
85+
skip_interstitial?: boolean;
86+
}
87+
88+
export interface SettingEditResponse {
89+
/**
90+
* Enables loading application content in an iFrame.
91+
*/
92+
allow_iframe?: boolean;
93+
94+
/**
95+
* Enables automatic authentication through cloudflared.
96+
*/
97+
skip_interstitial?: boolean;
98+
}
99+
100+
export interface SettingUpdateParams {
101+
/**
102+
* Path param: The Account ID to use for this endpoint. Mutually exclusive with the
103+
* Zone ID.
104+
*/
105+
account_id?: string;
106+
107+
/**
108+
* Path param: The Zone ID to use for this endpoint. Mutually exclusive with the
109+
* Account ID.
110+
*/
111+
zone_id?: string;
112+
113+
/**
114+
* Body param: Enables loading application content in an iFrame.
115+
*/
116+
allow_iframe?: boolean;
117+
118+
/**
119+
* Body param: Enables automatic authentication through cloudflared.
120+
*/
121+
skip_interstitial?: boolean;
122+
}
123+
124+
export interface SettingEditParams {
125+
/**
126+
* Path param: The Account ID to use for this endpoint. Mutually exclusive with the
127+
* Zone ID.
128+
*/
129+
account_id?: string;
130+
131+
/**
132+
* Path param: The Zone ID to use for this endpoint. Mutually exclusive with the
133+
* Account ID.
134+
*/
135+
zone_id?: string;
136+
137+
/**
138+
* Body param: Enables loading application content in an iFrame.
139+
*/
140+
allow_iframe?: boolean;
141+
142+
/**
143+
* Body param: Enables automatic authentication through cloudflared.
144+
*/
145+
skip_interstitial?: boolean;
146+
}
147+
148+
export declare namespace Settings {
149+
export {
150+
type SettingUpdateResponse as SettingUpdateResponse,
151+
type SettingEditResponse as SettingEditResponse,
152+
type SettingUpdateParams as SettingUpdateParams,
153+
type SettingEditParams as SettingEditParams,
154+
};
155+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Cloudflare from 'cloudflare';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new Cloudflare({
7+
apiKey: '144c9defac04969c7bfad8efaa8ea194',
8+
apiEmail: '[email protected]',
9+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
10+
});
11+
12+
describe('resource settings', () => {
13+
test('update', async () => {
14+
const responsePromise = client.zeroTrust.access.applications.settings.update(
15+
'023e105f4ecef8ad9ca31a8372d0c353',
16+
{ account_id: 'account_id' },
17+
);
18+
const rawResponse = await responsePromise.asResponse();
19+
expect(rawResponse).toBeInstanceOf(Response);
20+
const response = await responsePromise;
21+
expect(response).not.toBeInstanceOf(Response);
22+
const dataAndResponse = await responsePromise.withResponse();
23+
expect(dataAndResponse.data).toBe(response);
24+
expect(dataAndResponse.response).toBe(rawResponse);
25+
});
26+
27+
test('edit', async () => {
28+
const responsePromise = client.zeroTrust.access.applications.settings.edit(
29+
'023e105f4ecef8ad9ca31a8372d0c353',
30+
{ account_id: 'account_id' },
31+
);
32+
const rawResponse = await responsePromise.asResponse();
33+
expect(rawResponse).toBeInstanceOf(Response);
34+
const response = await responsePromise;
35+
expect(response).not.toBeInstanceOf(Response);
36+
const dataAndResponse = await responsePromise.withResponse();
37+
expect(dataAndResponse.data).toBe(response);
38+
expect(dataAndResponse.response).toBe(rawResponse);
39+
});
40+
});

0 commit comments

Comments
 (0)