diff --git a/src/management/__generated/managers/network-acls-manager.ts b/src/management/__generated/managers/network-acls-manager.ts index 2df7648e64..714495f8dd 100644 --- a/src/management/__generated/managers/network-acls-manager.ts +++ b/src/management/__generated/managers/network-acls-manager.ts @@ -3,11 +3,14 @@ import type { InitOverride, ApiResponse } from '../../../lib/runtime.js'; import type { GetNetworkAcls200Response, GetNetworkAclsById200Response, + PatchNetworkAclsById200Response, + PatchNetworkAclsByIdRequest, PutNetworkAclsByIdRequest, GetNetworkAcls200ResponseOneOf, DeleteNetworkAclsByIdRequest, GetNetworkAclsRequest, GetNetworkAclsByIdRequest, + PatchNetworkAclsByIdOperationRequest, PutNetworkAclsByIdOperationRequest, } from '../models/index.js'; @@ -114,6 +117,39 @@ export class NetworkAclsManager extends BaseAPI { return runtime.JSONApiResponse.fromResponse(response); } + /** + * Update existing access control list for your client. + * Partial Update for an Access Control List + * + * @throws {RequiredError} + */ + async patch( + requestParameters: PatchNetworkAclsByIdOperationRequest, + bodyParameters: PatchNetworkAclsByIdRequest, + initOverrides?: InitOverride + ): Promise> { + runtime.validateRequiredRequestParams(requestParameters, ['id']); + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request( + { + path: `/network-acls/{id}`.replace( + '{id}', + encodeURIComponent(String(requestParameters.id)) + ), + method: 'PATCH', + headers: headerParameters, + body: bodyParameters, + }, + initOverrides + ); + + return runtime.JSONApiResponse.fromResponse(response); + } + /** * Create a new access control list for your client. * Create Access Control List diff --git a/src/management/__generated/models/index.ts b/src/management/__generated/models/index.ts index 7c0b6761bc..1aa0d0b9a1 100644 --- a/src/management/__generated/models/index.ts +++ b/src/management/__generated/models/index.ts @@ -10510,6 +10510,170 @@ export const PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum = { export type PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum = (typeof PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum)[keyof typeof PatchLogStreamsByIdRequestSinkOneOf3MixpanelRegionEnum]; +/** + * + */ +export interface PatchNetworkAclsById200Response { + [key: string]: any | any; + /** + */ + id?: string; + /** + */ + description?: string; + /** + */ + active?: boolean; + /** + */ + priority?: number; + /** + */ + rule?: PatchNetworkAclsByIdRequestRule; + /** + * The timestamp when the Network ACL Configuration was created + * + */ + created_at?: string; + /** + * The timestamp when the Network ACL Configuration was last updated + * + */ + updated_at?: string; +} +/** + * + */ +export interface PatchNetworkAclsByIdRequest { + /** + */ + description?: string; + /** + * Indicates whether or not this access control list is actively being used + * + */ + active?: boolean; + /** + * Indicates the order in which the ACL will be evaluated relative to other ACL rules. + * + */ + priority?: number; + /** + */ + rule?: PatchNetworkAclsByIdRequestRule; +} +/** + * + */ +export interface PatchNetworkAclsByIdRequestRule { + /** + */ + action: PatchNetworkAclsByIdRequestRuleAction; + /** + */ + match?: PatchNetworkAclsByIdRequestRuleMatch; + /** + */ + not_match?: PatchNetworkAclsByIdRequestRuleMatch; + /** + * Identifies the origin of the request as the Management API (management), Authentication API (authentication), or either (tenant) + * + */ + scope: PatchNetworkAclsByIdRequestRuleScopeEnum; +} + +export const PatchNetworkAclsByIdRequestRuleScopeEnum = { + management: 'management', + authentication: 'authentication', + tenant: 'tenant', +} as const; +export type PatchNetworkAclsByIdRequestRuleScopeEnum = + (typeof PatchNetworkAclsByIdRequestRuleScopeEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleScopeEnum]; + +/** + * + */ +export interface PatchNetworkAclsByIdRequestRuleAction { + /** + * Indicates the rule will block requests that either match or not_match specific criteria + * + */ + block?: PatchNetworkAclsByIdRequestRuleActionBlockEnum; + /** + * Indicates the rule will allow requests that either match or not_match specific criteria + * + */ + allow?: PatchNetworkAclsByIdRequestRuleActionAllowEnum; + /** + * Indicates the rule will log requests that either match or not_match specific criteria + * + */ + log?: PatchNetworkAclsByIdRequestRuleActionLogEnum; + /** + * Indicates the rule will redirect requests that either match or not_match specific criteria + * + */ + redirect?: PatchNetworkAclsByIdRequestRuleActionRedirectEnum; + /** + * The URI to which the match or not_match requests will be routed + * + */ + redirect_uri?: string; +} + +export const PatchNetworkAclsByIdRequestRuleActionBlockEnum = { + true: true, +} as const; +export type PatchNetworkAclsByIdRequestRuleActionBlockEnum = + (typeof PatchNetworkAclsByIdRequestRuleActionBlockEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionBlockEnum]; + +export const PatchNetworkAclsByIdRequestRuleActionAllowEnum = { + true: true, +} as const; +export type PatchNetworkAclsByIdRequestRuleActionAllowEnum = + (typeof PatchNetworkAclsByIdRequestRuleActionAllowEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionAllowEnum]; + +export const PatchNetworkAclsByIdRequestRuleActionLogEnum = { + true: true, +} as const; +export type PatchNetworkAclsByIdRequestRuleActionLogEnum = + (typeof PatchNetworkAclsByIdRequestRuleActionLogEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionLogEnum]; + +export const PatchNetworkAclsByIdRequestRuleActionRedirectEnum = { + true: true, +} as const; +export type PatchNetworkAclsByIdRequestRuleActionRedirectEnum = + (typeof PatchNetworkAclsByIdRequestRuleActionRedirectEnum)[keyof typeof PatchNetworkAclsByIdRequestRuleActionRedirectEnum]; + +/** + * + */ +export interface PatchNetworkAclsByIdRequestRuleMatch { + /** + */ + asns?: Array; + /** + */ + geo_country_codes?: Array; + /** + */ + geo_subdivision_codes?: Array; + /** + */ + ipv4_cidrs?: Array; + /** + */ + ipv6_cidrs?: Array; + /** + */ + ja3_fingerprints?: Array; + /** + */ + ja4_fingerprints?: Array; + /** + */ + user_agents?: Array; +} /** * */ @@ -20510,6 +20674,16 @@ export interface GetNetworkAclsByIdRequest { */ id: string; } +/** + * + */ +export interface PatchNetworkAclsByIdOperationRequest { + /** + * The id of the ACL to update. + * + */ + id: string; +} /** * */ diff --git a/test/management/network-acls.test.ts b/test/management/network-acls.test.ts index 64bf93fe52..f50589f88f 100644 --- a/test/management/network-acls.test.ts +++ b/test/management/network-acls.test.ts @@ -3,6 +3,7 @@ import { NetworkAclsManager, ManagementClient, PutNetworkAclsByIdRequest, + PatchNetworkAclsByIdRequest, } from '../../src/index.js'; const API_URL = 'https://tenant.auth0.com/api/v2'; @@ -248,4 +249,60 @@ describe('NetworkAclsManager', () => { }); }); }); + + describe('#patch', () => { + const data = { id: 'acl_123' }; + + const body: PatchNetworkAclsByIdRequest = { + description: 'Patch ACL', + active: true, + rule: { + action: { + block: true, + }, + scope: 'tenant', + }, + }; + + beforeEach(() => { + request = nock(API_URL).patch(`/network-acls/${data.id}`).reply(200, body); + }); + + it('should return a promise if no callback is given', (done) => { + networkAcls + .patch(data, body as any) + .then(done.bind(null, null)) + .catch(done.bind(null, null)); + }); + + it('should pass any errors to the promise catch handler', (done) => { + nock.cleanAll(); + + nock(API_URL).patch(`/network-acls/${data.id}`).reply(500, {}); + + networkAcls.patch(data, body).catch((err) => { + expect(err).toBeDefined(); + done(); + }); + }); + + it('should perform a PATCH request to /api/v2/network-acls/:id', (done) => { + networkAcls.patch(data, body as any).then(() => { + expect(request.isDone()).toBe(true); + done(); + }); + }); + it('should pass the data in the body of the request', (done) => { + nock.cleanAll(); + + const request = nock(API_URL) + .patch(`/network-acls/${data.id}`, body as any) + .reply(200, body); + + networkAcls.patch(data, body).then(() => { + expect(request.isDone()).toBe(true); + done(); + }); + }); + }); });