11# coding: utf-8
22
3- # (C) Copyright IBM Corp. 2023 .
3+ # (C) Copyright IBM Corp. 2024 .
44#
55# Licensed under the Apache License, Version 2.0 (the "License");
66# you may not use this file except in compliance with the License.
1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17- # IBM OpenAPI SDK Code Generator Version: 3.81 .0-c73a091c-20231026-215706
17+ # IBM OpenAPI SDK Code Generator Version: 3.84 .0-a4533f12-20240103-170852
1818
1919"""
2020IAM Policy Management API
@@ -345,8 +345,90 @@ def replace_policy(
345345 resource attributes supported by the service. To view a service's or the
346346 platform's supported attributes, check the [documentation](/docs?tab=all-docs).
347347 The policy resource must include either the **`serviceType`**, **`serviceName`**,
348- or **`resourceGroupId`** attribute and the **`accountId`** attribute.` If the
348+ or **`resourceGroupId`** attribute and the **`accountId`** attribute.`
349+ In the rule field, you can specify a single condition by using **`key`**,
350+ **`value`**, and condition **`operator`**, or a set of **`conditions`** with a
351+ combination **`operator`**. The possible combination operators are **`and`** and
352+ **`or`**.
353+ Currently, we support two types of patterns:
354+ 1. `time-based`: Used to specify a time-based restriction
355+ Combine conditions to specify a time-based restriction (e.g., access only during
356+ business hours, during the Monday-Friday work week). For example, a policy can
357+ grant access Monday-Friday, 9:00am-5:00pm using the following rule:
358+ ```json
359+ "rule": {
360+ "operator": "and",
361+ "conditions": [{
362+ "key": "{{environment.attributes.day_of_week}}",
363+ "operator": "dayOfWeekAnyOf",
364+ "value": ["1+00:00", "2+00:00", "3+00:00", "4+00:00", "5+00:00"]
365+ },
366+ "key": "{{environment.attributes.current_time}}",
367+ "operator": "timeGreaterThanOrEquals",
368+ "value": "09:00:00+00:00"
369+ },
370+ "key": "{{environment.attributes.current_time}}",
371+ "operator": "timeLessThanOrEquals",
372+ "value": "17:00:00+00:00"
373+ }]
374+ }
375+ ``` You can use the following operators in the **`key`** and **`value`** pair:
376+ ```
377+ 'timeLessThan', 'timeLessThanOrEquals', 'timeGreaterThan',
378+ 'timeGreaterThanOrEquals',
379+ 'dateTimeLessThan', 'dateTimeLessThanOrEquals', 'dateTimeGreaterThan',
380+ 'dateTimeGreaterThanOrEquals',
381+ 'dayOfWeekEquals', 'dayOfWeekAnyOf',
382+ ``` The pattern field that matches the rule is required when rule is provided. For
383+ the business hour rule example above, the **`pattern`** is
384+ **`"time-based-conditions:weekly"`**. For more information, see [Time-based
385+ conditions
386+ operators](/docs/account?topic=account-iam-condition-properties&interface=ui#policy-condition-properties)
387+ and
388+ [Limiting access with time-based
389+ conditions](/docs/account?topic=account-iam-time-based&interface=ui). If the
349390 subject is a locked service-id, the request will fail.
391+ 2. `attribute-based`: Used to specify a combination of OR/AND based conditions
392+ applied on resource attributes.
393+ Combine conditions to specify an attribute-based condition using AN/OR-based
394+ operators.
395+ For example, a policy can grant access based on multiple conditions applied on the
396+ resource attributes below:
397+ ```json
398+ "pattern": "attribute-based-condition:resource:literal-and-wildcard"
399+ "rule": {
400+ "operator": "or",
401+ "conditions": [
402+ {
403+ "operator": "and",
404+ "conditions": [
405+ {
406+ "key": "{{resource.attributes.prefix}}",
407+ "operator": "stringEquals",
408+ "value": "home/test"
409+ },
410+ {
411+ "key": "{{environment.attributes.delimiter}}",
412+ "operator": "stringEquals",
413+ "value": "/"
414+ }
415+ ]
416+ },
417+ {
418+ "key": "{{resource.attributes.path}}",
419+ "operator": "stringMatch",
420+ "value": "home/David/*"
421+ }
422+ ]
423+ }
424+ ```
425+ In addition to satisfying the `resources` section, the policy grants permission
426+ only if either the `path` begins with `home/David/` **OR** the `prefix` is
427+ `home/test` and the `delimiter` is `/`. This mechanism helps you consolidate
428+ multiple policies in to a single policy, making policies easier to administer and
429+ stay within the policy limit for an account. View the list of operators that can
430+ be used in the condition
431+ [here](/docs/account?topic=account-wildcard#string-comparisons).
350432 ### Authorization
351433 To update an authorization policy, use **`"type": "authorization"`** in the body.
352434 The subject attributes must match the supported authorization subjects of the
@@ -1528,6 +1610,7 @@ def list_policy_templates(
15281610 account_id : str ,
15291611 * ,
15301612 accept_language : Optional [str ] = None ,
1613+ state : Optional [str ] = None ,
15311614 ** kwargs ,
15321615 ) -> DetailedResponse :
15331616 """
@@ -1554,6 +1637,7 @@ def list_policy_templates(
15541637 * `pt-br` - Portuguese (Brazil)
15551638 * `zh-cn` - Chinese (Simplified, PRC)
15561639 * `zh-tw` - (Chinese, Taiwan).
1640+ :param str state: (optional) The policy template state.
15571641 :param dict headers: A `dict` containing the request headers
15581642 :return: A `DetailedResponse` containing the result, headers and HTTP status code.
15591643 :rtype: DetailedResponse with `dict` result representing a `PolicyTemplateCollection` object
@@ -1573,6 +1657,7 @@ def list_policy_templates(
15731657
15741658 params = {
15751659 'account_id' : account_id ,
1660+ 'state' : state ,
15761661 }
15771662
15781663 if 'headers' in kwargs :
@@ -1684,6 +1769,8 @@ def create_policy_template(
16841769 def get_policy_template (
16851770 self ,
16861771 policy_template_id : str ,
1772+ * ,
1773+ state : Optional [str ] = None ,
16871774 ** kwargs ,
16881775 ) -> DetailedResponse :
16891776 """
@@ -1693,6 +1780,7 @@ def get_policy_template(
16931780 ID.
16941781
16951782 :param str policy_template_id: The policy template ID.
1783+ :param str state: (optional) The policy template state.
16961784 :param dict headers: A `dict` containing the request headers
16971785 :return: A `DetailedResponse` containing the result, headers and HTTP status code.
16981786 :rtype: DetailedResponse with `dict` result representing a `PolicyTemplate` object
@@ -1708,6 +1796,10 @@ def get_policy_template(
17081796 )
17091797 headers .update (sdk_headers )
17101798
1799+ params = {
1800+ 'state' : state ,
1801+ }
1802+
17111803 if 'headers' in kwargs :
17121804 headers .update (kwargs .get ('headers' ))
17131805 del kwargs ['headers' ]
@@ -1721,6 +1813,7 @@ def get_policy_template(
17211813 method = 'GET' ,
17221814 url = url ,
17231815 headers = headers ,
1816+ params = params ,
17241817 )
17251818
17261819 response = self .send (request , ** kwargs )
@@ -1849,6 +1942,8 @@ def create_policy_template_version(
18491942 def list_policy_template_versions (
18501943 self ,
18511944 policy_template_id : str ,
1945+ * ,
1946+ state : Optional [str ] = None ,
18521947 ** kwargs ,
18531948 ) -> DetailedResponse :
18541949 """
@@ -1857,6 +1952,7 @@ def list_policy_template_versions(
18571952 Retrieve the versions of a policy template by providing a policy template ID.
18581953
18591954 :param str policy_template_id: The policy template ID.
1955+ :param str state: (optional) The policy template state.
18601956 :param dict headers: A `dict` containing the request headers
18611957 :return: A `DetailedResponse` containing the result, headers and HTTP status code.
18621958 :rtype: DetailedResponse with `dict` result representing a `PolicyTemplateVersionsCollection` object
@@ -1872,6 +1968,10 @@ def list_policy_template_versions(
18721968 )
18731969 headers .update (sdk_headers )
18741970
1971+ params = {
1972+ 'state' : state ,
1973+ }
1974+
18751975 if 'headers' in kwargs :
18761976 headers .update (kwargs .get ('headers' ))
18771977 del kwargs ['headers' ]
@@ -1885,6 +1985,7 @@ def list_policy_template_versions(
18851985 method = 'GET' ,
18861986 url = url ,
18871987 headers = headers ,
1988+ params = params ,
18881989 )
18891990
18901991 response = self .send (request , ** kwargs )
@@ -2368,6 +2469,48 @@ class Format(str, Enum):
23682469 DISPLAY = 'display'
23692470
23702471
2472+ class ListPolicyTemplatesEnums :
2473+ """
2474+ Enums for list_policy_templates parameters.
2475+ """
2476+
2477+ class State (str , Enum ):
2478+ """
2479+ The policy template state.
2480+ """
2481+
2482+ ACTIVE = 'active'
2483+ DELETED = 'deleted'
2484+
2485+
2486+ class GetPolicyTemplateEnums :
2487+ """
2488+ Enums for get_policy_template parameters.
2489+ """
2490+
2491+ class State (str , Enum ):
2492+ """
2493+ The policy template state.
2494+ """
2495+
2496+ ACTIVE = 'active'
2497+ DELETED = 'deleted'
2498+
2499+
2500+ class ListPolicyTemplateVersionsEnums :
2501+ """
2502+ Enums for list_policy_template_versions parameters.
2503+ """
2504+
2505+ class State (str , Enum ):
2506+ """
2507+ The policy template state.
2508+ """
2509+
2510+ ACTIVE = 'active'
2511+ DELETED = 'deleted'
2512+
2513+
23712514##############################################################################
23722515# Models
23732516##############################################################################
@@ -3310,7 +3453,7 @@ def __ne__(self, other: 'LimitData') -> bool:
33103453
33113454class NestedCondition :
33123455 """
3313- Condition that specifies additional conditions or RuleAttribute to grant access.s.
3456+ Condition that specifies additional conditions or RuleAttribute to grant access.
33143457
33153458 """
33163459
@@ -4290,6 +4433,7 @@ class PolicyTemplate:
42904433 :param bool committed: (optional) Committed status of the template version.
42914434 :param TemplatePolicy policy: The core set of properties associated with the
42924435 template's policy objet.
4436+ :param str state: (optional) State of policy template.
42934437 :param str id: (optional) The policy template ID.
42944438 :param str href: (optional) The href URL that links to the policy templates API
42954439 by policy template ID.
@@ -4312,6 +4456,7 @@ def __init__(
43124456 * ,
43134457 description : Optional [str ] = None ,
43144458 committed : Optional [bool ] = None ,
4459+ state : Optional [str ] = None ,
43154460 id : Optional [str ] = None ,
43164461 href : Optional [str ] = None ,
43174462 created_at : Optional [datetime ] = None ,
@@ -4335,13 +4480,15 @@ def __init__(
43354480 purpose or context of the policy for enterprise users managing IAM
43364481 templates.
43374482 :param bool committed: (optional) Committed status of the template version.
4483+ :param str state: (optional) State of policy template.
43384484 """
43394485 self .name = name
43404486 self .description = description
43414487 self .account_id = account_id
43424488 self .version = version
43434489 self .committed = committed
43444490 self .policy = policy
4491+ self .state = state
43454492 self .id = id
43464493 self .href = href
43474494 self .created_at = created_at
@@ -4373,6 +4520,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplate':
43734520 args ['policy' ] = TemplatePolicy .from_dict (_dict .get ('policy' ))
43744521 else :
43754522 raise ValueError ('Required property \' policy\' not present in PolicyTemplate JSON' )
4523+ if 'state' in _dict :
4524+ args ['state' ] = _dict .get ('state' )
43764525 if 'id' in _dict :
43774526 args ['id' ] = _dict .get ('id' )
43784527 if 'href' in _dict :
@@ -4410,6 +4559,8 @@ def to_dict(self) -> Dict:
44104559 _dict ['policy' ] = self .policy
44114560 else :
44124561 _dict ['policy' ] = self .policy .to_dict ()
4562+ if hasattr (self , 'state' ) and self .state is not None :
4563+ _dict ['state' ] = self .state
44134564 if hasattr (self , 'id' ) and getattr (self , 'id' ) is not None :
44144565 _dict ['id' ] = getattr (self , 'id' )
44154566 if hasattr (self , 'href' ) and getattr (self , 'href' ) is not None :
@@ -4442,6 +4593,14 @@ def __ne__(self, other: 'PolicyTemplate') -> bool:
44424593 """Return `true` when self and other are not equal, false otherwise."""
44434594 return not self == other
44444595
4596+ class StateEnum (str , Enum ):
4597+ """
4598+ State of policy template.
4599+ """
4600+
4601+ ACTIVE = 'active'
4602+ DELETED = 'deleted'
4603+
44454604
44464605class PolicyTemplateAssignmentCollection :
44474606 """
@@ -4591,6 +4750,7 @@ class PolicyTemplateLimitData:
45914750 :param bool committed: (optional) Committed status of the template version.
45924751 :param TemplatePolicy policy: The core set of properties associated with the
45934752 template's policy objet.
4753+ :param str state: (optional) State of policy template.
45944754 :param str id: (optional) The policy template ID.
45954755 :param str href: (optional) The href URL that links to the policy templates API
45964756 by policy template ID.
@@ -4614,6 +4774,7 @@ def __init__(
46144774 * ,
46154775 description : Optional [str ] = None ,
46164776 committed : Optional [bool ] = None ,
4777+ state : Optional [str ] = None ,
46174778 id : Optional [str ] = None ,
46184779 href : Optional [str ] = None ,
46194780 created_at : Optional [datetime ] = None ,
@@ -4638,6 +4799,7 @@ def __init__(
46384799 purpose or context of the policy for enterprise users managing IAM
46394800 templates.
46404801 :param bool committed: (optional) Committed status of the template version.
4802+ :param str state: (optional) State of policy template.
46414803 :param TemplateCountData counts: (optional) policy template count details.
46424804 """
46434805 self .name = name
@@ -4646,6 +4808,7 @@ def __init__(
46464808 self .version = version
46474809 self .committed = committed
46484810 self .policy = policy
4811+ self .state = state
46494812 self .id = id
46504813 self .href = href
46514814 self .created_at = created_at
@@ -4678,6 +4841,8 @@ def from_dict(cls, _dict: Dict) -> 'PolicyTemplateLimitData':
46784841 args ['policy' ] = TemplatePolicy .from_dict (_dict .get ('policy' ))
46794842 else :
46804843 raise ValueError ('Required property \' policy\' not present in PolicyTemplateLimitData JSON' )
4844+ if 'state' in _dict :
4845+ args ['state' ] = _dict .get ('state' )
46814846 if 'id' in _dict :
46824847 args ['id' ] = _dict .get ('id' )
46834848 if 'href' in _dict :
@@ -4717,6 +4882,8 @@ def to_dict(self) -> Dict:
47174882 _dict ['policy' ] = self .policy
47184883 else :
47194884 _dict ['policy' ] = self .policy .to_dict ()
4885+ if hasattr (self , 'state' ) and self .state is not None :
4886+ _dict ['state' ] = self .state
47204887 if hasattr (self , 'id' ) and getattr (self , 'id' ) is not None :
47214888 _dict ['id' ] = getattr (self , 'id' )
47224889 if hasattr (self , 'href' ) and getattr (self , 'href' ) is not None :
@@ -4754,6 +4921,14 @@ def __ne__(self, other: 'PolicyTemplateLimitData') -> bool:
47544921 """Return `true` when self and other are not equal, false otherwise."""
47554922 return not self == other
47564923
4924+ class StateEnum (str , Enum ):
4925+ """
4926+ State of policy template.
4927+ """
4928+
4929+ ACTIVE = 'active'
4930+ DELETED = 'deleted'
4931+
47574932
47584933class PolicyTemplateMetaData :
47594934 """
0 commit comments