Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 168 additions & 3 deletions cis/zones-settings/v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/**
* IBM OpenAPI SDK Code Generator Version: 3.112.0-f88e9264-20260220-115155
* IBM OpenAPI SDK Code Generator Version: 3.114.0-a902401e-20260427-192904
*/

import * as extend from 'extend';
Expand Down Expand Up @@ -4463,6 +4463,117 @@ class ZonesSettingsV1 extends BaseService {

return this.createRequest(parameters);
}

/**
* Get security level setting.
*
* Get security level for a zone.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<ZonesSettingsV1.Response<ZonesSettingsV1.SecurityLevelResp>>}
*/
public getSecurityLevel(
params?: ZonesSettingsV1.GetSecurityLevelParams
): Promise<ZonesSettingsV1.Response<ZonesSettingsV1.SecurityLevelResp>> {
const _params = { ...params };
const _requiredParams = [];
const _validParams = ['signal', 'headers'];
const _validationErrors = validateParams(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}

const path = {
'crn': this.crn,
'zone_identifier': this.zoneIdentifier,
};

const sdkHeaders = getSdkHeaders(ZonesSettingsV1.DEFAULT_SERVICE_NAME, 'v1', 'getSecurityLevel');

const parameters = {
options: {
url: '/v1/{crn}/zones/{zone_identifier}/settings/security_level',
method: 'GET',
path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(
true,
sdkHeaders,
this.baseOptions.headers,
{
'Accept': 'application/json',
},
_params.headers
),
axiosOptions: {
signal: _params.signal,
},
}),
};

return this.createRequest(parameters);
}

/**
* Update security level setting.
*
* Update security level setting for a zone.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {string} [params.value] - Value.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<ZonesSettingsV1.Response<ZonesSettingsV1.SecurityLevelResp>>}
*/
public updateSecurityLevel(
params?: ZonesSettingsV1.UpdateSecurityLevelParams
): Promise<ZonesSettingsV1.Response<ZonesSettingsV1.SecurityLevelResp>> {
const _params = { ...params };
const _requiredParams = [];
const _validParams = ['value', 'signal', 'headers'];
const _validationErrors = validateParams(_params, _requiredParams, _validParams);
if (_validationErrors) {
return Promise.reject(_validationErrors);
}

const body = {
'value': _params.value,
};

const path = {
'crn': this.crn,
'zone_identifier': this.zoneIdentifier,
};

const sdkHeaders = getSdkHeaders(ZonesSettingsV1.DEFAULT_SERVICE_NAME, 'v1', 'updateSecurityLevel');

const parameters = {
options: {
url: '/v1/{crn}/zones/{zone_identifier}/settings/security_level',
method: 'PATCH',
body,
path,
},
defaultOptions: extend(true, {}, this.baseOptions, {
headers: extend(
true,
sdkHeaders,
this.baseOptions.headers,
{
'Accept': 'application/json',
'Content-Type': 'application/json',
},
_params.headers
),
axiosOptions: {
signal: _params.signal,
},
}),
};

return this.createRequest(parameters);
}
}

/*************************
Expand Down Expand Up @@ -5214,6 +5325,28 @@ namespace ZonesSettingsV1 {
}
}

/** Parameters for the `getSecurityLevel` operation. */
export interface GetSecurityLevelParams extends DefaultParams {
}

/** Parameters for the `updateSecurityLevel` operation. */
export interface UpdateSecurityLevelParams extends DefaultParams {
/** Value. */
value?: UpdateSecurityLevelConstants.Value | string;
}

/** Constants for the `updateSecurityLevel` operation. */
export namespace UpdateSecurityLevelConstants {
/** Value. */
export enum Value {
ESSENTIALLY_OFF = 'essentially_off',
LOW = 'low',
MEDIUM = 'medium',
HIGH = 'high',
UNDER_ATTACK = 'under_attack',
}
}

/*************************
* model interfaces
************************/
Expand Down Expand Up @@ -5313,7 +5446,7 @@ namespace ZonesSettingsV1 {
/** Editable. */
editable: boolean;
/** Modified date. */
modified_on: string;
modified_on?: string;
}

/**
Expand Down Expand Up @@ -5691,7 +5824,7 @@ namespace ZonesSettingsV1 {
/** Editable. */
editable: boolean;
/** Modified date. */
modified_on: string;
modified_on?: string;
}

/**
Expand Down Expand Up @@ -5784,6 +5917,20 @@ namespace ZonesSettingsV1 {
nosniff: boolean;
}

/**
* Container for response information.
*/
export interface SecurityLevelRespResult {
/** ID. */
id: string;
/** Value. */
value: string;
/** Editable. */
editable: boolean;
/** Modified date. */
modified_on?: string;
}

/**
* Container for response information.
*/
Expand Down Expand Up @@ -6042,6 +6189,8 @@ namespace ZonesSettingsV1 {
export interface EmailObfuscationResp {
/** Container for response information. */
result: EmailObfuscationRespResult;
/** Result information. */
result_info?: JsonObject;
/** Was the get successful. */
success: boolean;
/** Array of errors encountered. */
Expand Down Expand Up @@ -6335,6 +6484,8 @@ namespace ZonesSettingsV1 {
export interface ReplaceInsecureJsResp {
/** Container for response information. */
result: ReplaceInsecureJsRespResult;
/** Result information. */
result_info?: JsonObject;
/** Was the get successful. */
success: boolean;
/** Array of errors encountered. */
Expand Down Expand Up @@ -6385,6 +6536,20 @@ namespace ZonesSettingsV1 {
messages: string[][];
}

/**
* Security level response.
*/
export interface SecurityLevelResp {
/** Container for response information. */
result: SecurityLevelRespResult;
/** Was the get successful. */
success: boolean;
/** Array of errors encountered. */
errors: string[][];
/** Array of messages returned. */
messages: string[][];
}

/**
* Response of server side exclude.
*/
Expand Down
47 changes: 46 additions & 1 deletion test/integration/cis/zones-settings.v1.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2077,4 +2077,49 @@ describe.skip('Zones Settings', () => {
});
});
});
});

describe('Security Level', () => {
let securityLevelInstance;
beforeAll(() => {
securityLevelInstance = ZoneSettingsApi.newInstance({
authenticator: new IamAuthenticator({
apikey: config.CIS_SERVICES_APIKEY,
url: config.CIS_SERVICES_AUTH_URL,
}),
crn: config.CIS_SERVICES_CRN,
serviceUrl: config.CIS_SERVICES_URL,
version: config.CIS_SERVICES_API_VERSION,
zoneIdentifier: config.CIS_SERVICES_ZONE_ID,
});
});

test('should successfully get security level setting', async () => {
const response = await securityLevelInstance.getSecurityLevel();
expect(response).toBeDefined();
expect(response.status).toEqual(200);

const { result } = response || {};

expect(result).toBeDefined();
if (result && result.result) {
expect(result.result).toBeDefined();
}
});

test('should successfully update security level setting', async () => {
const params = {
value: 'medium',
};
const response = await securityLevelInstance.updateSecurityLevel(params);
expect(response).toBeDefined();
expect(response.status).toEqual(200);

const { result } = response || {};

expect(result).toBeDefined();
if (result && result.result) {
expect(result.result).toBeDefined();
}
});
});
});
Loading
Loading