diff --git a/context-based-restrictions/v1.ts b/context-based-restrictions/v1.ts index 14163494..f7617e5e 100644 --- a/context-based-restrictions/v1.ts +++ b/context-based-restrictions/v1.ts @@ -15,7 +15,7 @@ */ /** - * IBM OpenAPI SDK Code Generator Version: 3.53.0-9710cac3-20220713-193508 + * IBM OpenAPI SDK Code Generator Version: 3.57.1-4c556507-20220928-143422 */ import * as extend from 'extend'; @@ -639,6 +639,7 @@ class ContextBasedRestrictionsV1 extends BaseService { * @param {string} [params.serviceInstance] - The `serviceInstance` resource attribute. * @param {string} [params.serviceName] - The `serviceName` resource attribute. * @param {string} [params.serviceType] - The rule's `serviceType` resource attribute. + * @param {string} [params.serviceGroupId] - The rule's `service_group_id` resource attribute. * @param {string} [params.zoneId] - The globally unique ID of the zone. * @param {string} [params.sort] - Sorts results by using a valid sort field. To learn more, see * [Sorting](https://cloud.ibm.com/docs/api-handbook?topic=api-handbook-sorting). @@ -661,6 +662,7 @@ class ContextBasedRestrictionsV1 extends BaseService { 'serviceInstance', 'serviceName', 'serviceType', + 'serviceGroupId', 'zoneId', 'sort', 'enforcementMode', @@ -679,6 +681,7 @@ class ContextBasedRestrictionsV1 extends BaseService { 'service_instance': _params.serviceInstance, 'service_name': _params.serviceName, 'service_type': _params.serviceType, + 'service_group_id': _params.serviceGroupId, 'zone_id': _params.zoneId, 'sort': _params.sort, 'enforcement_mode': _params.enforcementMode, @@ -1306,6 +1309,8 @@ namespace ContextBasedRestrictionsV1 { serviceName?: string; /** The rule's `serviceType` resource attribute. */ serviceType?: string; + /** The rule's `service_group_id` resource attribute. */ + serviceGroupId?: string; /** The globally unique ID of the zone. */ zoneId?: string; /** Sorts results by using a valid sort field. To learn more, see diff --git a/test/integration/context-based-restrictions.v1.test.js b/test/integration/context-based-restrictions.v1.test.js index 90f0f5af..f84181d2 100644 --- a/test/integration/context-based-restrictions.v1.test.js +++ b/test/integration/context-based-restrictions.v1.test.js @@ -580,6 +580,77 @@ describe('ContextBasedRestrictionsV1_integration', () => { }); }); + test('listRules() - List rule with valid service_group_id attribute', async () => { + // create new rule with service_group_id attribute + const ruleContextAttributeModel = { + name: 'networkZoneId', + value: zoneId, + }; + + const ruleContextModel = { + attributes: [ruleContextAttributeModel], + }; + + const resourceAttributeAccountIdModel = { + name: 'accountId', + value: accountId, + operator: 'stringEquals', + }; + + const resourceAttributeServiceGroupIDModel = { + name: 'service_group_id', + value: 'IAM', + }; + + const resourceModel = { + attributes: [resourceAttributeAccountIdModel, resourceAttributeServiceGroupIDModel], + }; + + const params = { + contexts: [ruleContextModel], + resources: [resourceModel], + description: 'this is an example of rule with a service_group_id', + enforcementMode: ContextBasedRestrictionsV1.CreateRuleConstants.EnforcementMode.ENABLED, + transactionId: uuidv4(), + }; + + let res; + try { + res = await contextBasedRestrictionsService.createRule(params); + } catch (err) { + console.warn(err); + } + + expect(res).toBeDefined(); + expect(res.status).toBe(201); + expect(res.result).toBeDefined(); + + // list rule with service_group_id attribute + const listParams = { + accountId, + serviceGroupId: 'IAM', + transactionId: uuidv4(), + }; + + const listRes = await contextBasedRestrictionsService.listRules(listParams); + expect(listRes).toBeDefined(); + expect(listRes.status).toBe(200); + expect(listRes.result).toBeDefined(); + expect(listRes.result.count).toBe(1); + expect(listRes.result.rules[0].id).toBe(res.result.id); + + // cleanup + const deleteParams = { + ruleId: res.result.id, + transactionId: uuidv4(), + }; + + const deleteRes = await contextBasedRestrictionsService.deleteRule(deleteParams); + expect(deleteRes).toBeDefined(); + expect(deleteRes.status).toBe(204); + expect(deleteRes.result).toBeDefined(); + }); + test('getRule() - Get the specified rule', async () => { const params = { ruleId, diff --git a/test/unit/context-based-restrictions.v1.test.js b/test/unit/context-based-restrictions.v1.test.js index 765dfec0..803f5505 100644 --- a/test/unit/context-based-restrictions.v1.test.js +++ b/test/unit/context-based-restrictions.v1.test.js @@ -794,6 +794,7 @@ describe('ContextBasedRestrictionsV1', () => { const serviceInstance = 'testString'; const serviceName = 'testString'; const serviceType = 'testString'; + const serviceGroupId = 'testString'; const zoneId = 'testString'; const sort = 'testString'; const enforcementMode = 'enabled'; @@ -807,6 +808,7 @@ describe('ContextBasedRestrictionsV1', () => { serviceInstance: serviceInstance, serviceName: serviceName, serviceType: serviceType, + serviceGroupId: serviceGroupId, zoneId: zoneId, sort: sort, enforcementMode: enforcementMode, @@ -835,6 +837,7 @@ describe('ContextBasedRestrictionsV1', () => { expect(mockRequestOptions.qs.service_instance).toEqual(serviceInstance); expect(mockRequestOptions.qs.service_name).toEqual(serviceName); expect(mockRequestOptions.qs.service_type).toEqual(serviceType); + expect(mockRequestOptions.qs.service_group_id).toEqual(serviceGroupId); expect(mockRequestOptions.qs.zone_id).toEqual(zoneId); expect(mockRequestOptions.qs.sort).toEqual(sort); expect(mockRequestOptions.qs.enforcement_mode).toEqual(enforcementMode);