Skip to content

Commit 35cb3cb

Browse files
authored
Add Tenant ACL GA Support (#1140)
2 parents cf502a0 + 1b32a7b commit 35cb3cb

3 files changed

Lines changed: 267 additions & 0 deletions

File tree

src/management/__generated/managers/network-acls-manager.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import type { InitOverride, ApiResponse } from '../../../lib/runtime.js';
33
import type {
44
GetNetworkAcls200Response,
55
GetNetworkAclsById200Response,
6+
PatchNetworkAclsById200Response,
7+
PatchNetworkAclsByIdRequest,
68
PutNetworkAclsByIdRequest,
79
GetNetworkAcls200ResponseOneOf,
810
DeleteNetworkAclsByIdRequest,
911
GetNetworkAclsRequest,
1012
GetNetworkAclsByIdRequest,
13+
PatchNetworkAclsByIdOperationRequest,
1114
PutNetworkAclsByIdOperationRequest,
1215
} from '../models/index.js';
1316

@@ -114,6 +117,39 @@ export class NetworkAclsManager extends BaseAPI {
114117
return runtime.JSONApiResponse.fromResponse(response);
115118
}
116119

120+
/**
121+
* Update existing access control list for your client.
122+
* Partial Update for an Access Control List
123+
*
124+
* @throws {RequiredError}
125+
*/
126+
async patch(
127+
requestParameters: PatchNetworkAclsByIdOperationRequest,
128+
bodyParameters: PatchNetworkAclsByIdRequest,
129+
initOverrides?: InitOverride
130+
): Promise<ApiResponse<PatchNetworkAclsById200Response>> {
131+
runtime.validateRequiredRequestParams(requestParameters, ['id']);
132+
133+
const headerParameters: runtime.HTTPHeaders = {};
134+
135+
headerParameters['Content-Type'] = 'application/json';
136+
137+
const response = await this.request(
138+
{
139+
path: `/network-acls/{id}`.replace(
140+
'{id}',
141+
encodeURIComponent(String(requestParameters.id))
142+
),
143+
method: 'PATCH',
144+
headers: headerParameters,
145+
body: bodyParameters,
146+
},
147+
initOverrides
148+
);
149+
150+
return runtime.JSONApiResponse.fromResponse(response);
151+
}
152+
117153
/**
118154
* Create a new access control list for your client.
119155
* Create Access Control List

src/management/__generated/models/index.ts

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10510,6 +10510,170 @@ export const PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum = {
1051010510
export type PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum =
1051110511
(typeof PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum)[keyof typeof PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum];
1051210512

10513+
/**
10514+
*
10515+
*/
10516+
export interface PatchNetworkAclsById200Response {
10517+
[key: string]: any | any;
10518+
/**
10519+
*/
10520+
id?: string;
10521+
/**
10522+
*/
10523+
description?: string;
10524+
/**
10525+
*/
10526+
active?: boolean;
10527+
/**
10528+
*/
10529+
priority?: number;
10530+
/**
10531+
*/
10532+
rule?: PatchNetworkAclsByIdRequestRule;
10533+
/**
10534+
* The timestamp when the Network ACL Configuration was created
10535+
*
10536+
*/
10537+
created_at?: string;
10538+
/**
10539+
* The timestamp when the Network ACL Configuration was last updated
10540+
*
10541+
*/
10542+
updated_at?: string;
10543+
}
10544+
/**
10545+
*
10546+
*/
10547+
export interface PatchNetworkAclsByIdRequest {
10548+
/**
10549+
*/
10550+
description?: string;
10551+
/**
10552+
* Indicates whether or not this access control list is actively being used
10553+
*
10554+
*/
10555+
active?: boolean;
10556+
/**
10557+
* Indicates the order in which the ACL will be evaluated relative to other ACL rules.
10558+
*
10559+
*/
10560+
priority?: number;
10561+
/**
10562+
*/
10563+
rule?: PatchNetworkAclsByIdRequestRule;
10564+
}
10565+
/**
10566+
*
10567+
*/
10568+
export interface PatchNetworkAclsByIdRequestRule {
10569+
/**
10570+
*/
10571+
action: PatchNetworkAclsByIdRequestRuleAction;
10572+
/**
10573+
*/
10574+
match?: PatchNetworkAclsByIdRequestRuleMatch;
10575+
/**
10576+
*/
10577+
not_match?: PatchNetworkAclsByIdRequestRuleMatch;
10578+
/**
10579+
* Identifies the origin of the request as the Management API (management), Authentication API (authentication), or either (tenant)
10580+
*
10581+
*/
10582+
scope: PatchNetworkAclsByIdRequestRuleScopeEnum;
10583+
}
10584+
10585+
export const PatchNetworkAclsByIdRequestRuleScopeEnum = {
10586+
management: 'management',
10587+
authentication: 'authentication',
10588+
tenant: 'tenant',
10589+
} as const;
10590+
export type PatchNetworkAclsByIdRequestRuleScopeEnum =
10591+
(typeof PatchNetworkAclsByIdRequestRuleScopeEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleScopeEnum];
10592+
10593+
/**
10594+
*
10595+
*/
10596+
export interface PatchNetworkAclsByIdRequestRuleAction {
10597+
/**
10598+
* Indicates the rule will block requests that either match or not_match specific criteria
10599+
*
10600+
*/
10601+
block?: PatchNetworkAclsByIdRequestRuleActionBlockEnum;
10602+
/**
10603+
* Indicates the rule will allow requests that either match or not_match specific criteria
10604+
*
10605+
*/
10606+
allow?: PatchNetworkAclsByIdRequestRuleActionAllowEnum;
10607+
/**
10608+
* Indicates the rule will log requests that either match or not_match specific criteria
10609+
*
10610+
*/
10611+
log?: PatchNetworkAclsByIdRequestRuleActionLogEnum;
10612+
/**
10613+
* Indicates the rule will redirect requests that either match or not_match specific criteria
10614+
*
10615+
*/
10616+
redirect?: PatchNetworkAclsByIdRequestRuleActionRedirectEnum;
10617+
/**
10618+
* The URI to which the match or not_match requests will be routed
10619+
*
10620+
*/
10621+
redirect_uri?: string;
10622+
}
10623+
10624+
export const PatchNetworkAclsByIdRequestRuleActionBlockEnum = {
10625+
true: true,
10626+
} as const;
10627+
export type PatchNetworkAclsByIdRequestRuleActionBlockEnum =
10628+
(typeof PatchNetworkAclsByIdRequestRuleActionBlockEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionBlockEnum];
10629+
10630+
export const PatchNetworkAclsByIdRequestRuleActionAllowEnum = {
10631+
true: true,
10632+
} as const;
10633+
export type PatchNetworkAclsByIdRequestRuleActionAllowEnum =
10634+
(typeof PatchNetworkAclsByIdRequestRuleActionAllowEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionAllowEnum];
10635+
10636+
export const PatchNetworkAclsByIdRequestRuleActionLogEnum = {
10637+
true: true,
10638+
} as const;
10639+
export type PatchNetworkAclsByIdRequestRuleActionLogEnum =
10640+
(typeof PatchNetworkAclsByIdRequestRuleActionLogEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionLogEnum];
10641+
10642+
export const PatchNetworkAclsByIdRequestRuleActionRedirectEnum = {
10643+
true: true,
10644+
} as const;
10645+
export type PatchNetworkAclsByIdRequestRuleActionRedirectEnum =
10646+
(typeof PatchNetworkAclsByIdRequestRuleActionRedirectEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionRedirectEnum];
10647+
10648+
/**
10649+
*
10650+
*/
10651+
export interface PatchNetworkAclsByIdRequestRuleMatch {
10652+
/**
10653+
*/
10654+
asns?: Array<number>;
10655+
/**
10656+
*/
10657+
geo_country_codes?: Array<string>;
10658+
/**
10659+
*/
10660+
geo_subdivision_codes?: Array<string>;
10661+
/**
10662+
*/
10663+
ipv4_cidrs?: Array<GetNetworkAclsById200ResponseRuleAnyOfMatchIpv4CidrsInner>;
10664+
/**
10665+
*/
10666+
ipv6_cidrs?: Array<GetNetworkAclsById200ResponseRuleAnyOfMatchIpv6CidrsInner>;
10667+
/**
10668+
*/
10669+
ja3_fingerprints?: Array<string>;
10670+
/**
10671+
*/
10672+
ja4_fingerprints?: Array<string>;
10673+
/**
10674+
*/
10675+
user_agents?: Array<string>;
10676+
}
1051310677
/**
1051410678
*
1051510679
*/
@@ -20510,6 +20674,16 @@ export interface GetNetworkAclsByIdRequest {
2051020674
*/
2051120675
id: string;
2051220676
}
20677+
/**
20678+
*
20679+
*/
20680+
export interface PatchNetworkAclsByIdOperationRequest {
20681+
/**
20682+
* The id of the ACL to update.
20683+
*
20684+
*/
20685+
id: string;
20686+
}
2051320687
/**
2051420688
*
2051520689
*/

test/management/network-acls.test.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
NetworkAclsManager,
44
ManagementClient,
55
PutNetworkAclsByIdRequest,
6+
PatchNetworkAclsByIdRequest,
67
} from '../../src/index.js';
78

89
const API_URL = 'https://tenant.auth0.com/api/v2';
@@ -248,4 +249,60 @@ describe('NetworkAclsManager', () => {
248249
});
249250
});
250251
});
252+
253+
describe('#patch', () => {
254+
const data = { id: 'acl_123' };
255+
256+
const body: PatchNetworkAclsByIdRequest = {
257+
description: 'Patch ACL',
258+
active: true,
259+
rule: {
260+
action: {
261+
block: true,
262+
},
263+
scope: 'tenant',
264+
},
265+
};
266+
267+
beforeEach(() => {
268+
request = nock(API_URL).patch(`/network-acls/${data.id}`).reply(200, body);
269+
});
270+
271+
it('should return a promise if no callback is given', (done) => {
272+
networkAcls
273+
.patch(data, body as any)
274+
.then(done.bind(null, null))
275+
.catch(done.bind(null, null));
276+
});
277+
278+
it('should pass any errors to the promise catch handler', (done) => {
279+
nock.cleanAll();
280+
281+
nock(API_URL).patch(`/network-acls/${data.id}`).reply(500, {});
282+
283+
networkAcls.patch(data, body).catch((err) => {
284+
expect(err).toBeDefined();
285+
done();
286+
});
287+
});
288+
289+
it('should perform a PATCH request to /api/v2/network-acls/:id', (done) => {
290+
networkAcls.patch(data, body as any).then(() => {
291+
expect(request.isDone()).toBe(true);
292+
done();
293+
});
294+
});
295+
it('should pass the data in the body of the request', (done) => {
296+
nock.cleanAll();
297+
298+
const request = nock(API_URL)
299+
.patch(`/network-acls/${data.id}`, body as any)
300+
.reply(200, body);
301+
302+
networkAcls.patch(data, body).then(() => {
303+
expect(request.isDone()).toBe(true);
304+
done();
305+
});
306+
});
307+
});
251308
});

0 commit comments

Comments
 (0)