Skip to content

Commit 18a33a8

Browse files
authored
Merge branch 'main' into iam-identity-adding-activity
2 parents 2c7a927 + e3c97a1 commit 18a33a8

File tree

9 files changed

+219
-317
lines changed

9 files changed

+219
-317
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.22.9
2+
current_version = 0.23.0
33
commit = True
44
message = Update version {current_version} -> {new_version}
55

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [0.23.0](https://github.com/IBM/platform-services-python-sdk/compare/v0.22.9...v0.23.0) (2022-04-04)
2+
3+
4+
### Features
5+
6+
* **IAM Access Groups:** add support for dynamic membership ([#154](https://github.com/IBM/platform-services-python-sdk/issues/154)) ([256792d](https://github.com/IBM/platform-services-python-sdk/commit/256792d1dc6cb1368821ae3ac1a5a81f24f9f1b8))
7+
18
## [0.22.9](https://github.com/IBM/platform-services-python-sdk/compare/v0.22.8...v0.22.9) (2022-03-21)
29

310

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![CLA assistant](https://cla-assistant.io/readme/badge/IBM/platform-services-python-sdk)](https://cla-assistant.io/IBM/platform-services-python-sdk)
99

1010

11-
# IBM Cloud Platform Services Python SDK Version 0.22.9
11+
# IBM Cloud Platform Services Python SDK Version 0.23.0
1212

1313
Python client library to interact with various
1414
[IBM Cloud Platform Service APIs](https://cloud.ibm.com/docs?tab=api-docs&category=platform_services).

examples/test_iam_access_groups_v2_examples.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@
3737
# in a configuration file and then:
3838
# export IBM_CREDENTIALS_FILE=<name of configuration file>
3939
#
40-
config_file = 'iam_access_groups.env'
40+
config_file = 'iam_access_groups_v2.env'
4141

4242
iam_access_groups_service = None
4343

4444
config = None
4545

4646
test_account_id = None
47+
test_profile_id = None
4748
test_group_etag = None
4849
test_group_id = None
4950
test_claim_rule_id = None
@@ -74,10 +75,11 @@ def setup_class(cls):
7475
assert iam_access_groups_service is not None
7576

7677
# Load the configuration
77-
global config, test_account_id
78+
global config, test_account_id, test_profile_id
7879
config = read_external_sources(
7980
IamAccessGroupsV2.DEFAULT_SERVICE_NAME)
8081
test_account_id = config['TEST_ACCOUNT_ID']
82+
test_profile_id = config['TEST_PROFILE_ID']
8183

8284
print('Setup complete.')
8385

@@ -188,7 +190,9 @@ def test_add_members_to_access_group_example(self):
188190
iam_id='IBMid-user1', type='user')
189191
member2 = AddGroupMembersRequestMembersItem(
190192
iam_id='iam-ServiceId-123', type='service')
191-
members = [member1, member2]
193+
member3 = AddGroupMembersRequestMembersItem(
194+
iam_id=test_profile_id, type='profile')
195+
members = [member1, member2, member3]
192196

193197
add_group_members_response = iam_access_groups_service.add_members_to_access_group(
194198
access_group_id=test_group_id,
@@ -281,6 +285,27 @@ def test_remove_members_from_access_group_example(self):
281285
except ApiException as e:
282286
pytest.fail(str(e))
283287

288+
@needscredentials
289+
def test_remove_profile_members_from_access_group_example(self):
290+
"""
291+
remove_members_from_access_group request example
292+
"""
293+
try:
294+
print('\nremove_members_from_access_group() result:')
295+
# begin-remove_members_from_access_group
296+
297+
delete_group_bulk_members_response = iam_access_groups_service.remove_members_from_access_group(
298+
access_group_id=test_group_id,
299+
members=[test_profile_id]
300+
).get_result()
301+
302+
print(json.dumps(delete_group_bulk_members_response, indent=2))
303+
304+
# end-remove_members_from_access_group
305+
306+
except ApiException as e:
307+
pytest.fail(str(e))
308+
284309
@needscredentials
285310
def test_add_member_to_multiple_access_groups_example(self):
286311
"""

ibm_platform_services/iam_access_groups_v2.py

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
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.43.4-432d779b-20220119-173927
17+
# IBM OpenAPI SDK Code Generator Version: 3.46.1-a5569134-20220316-164819
1818

1919
"""
2020
The IAM Access Groups API allows for the management of access groups (Create, Read,
@@ -161,6 +161,7 @@ def list_access_groups(self,
161161
*,
162162
transaction_id: str = None,
163163
iam_id: str = None,
164+
membership_type: str = None,
164165
limit: int = None,
165166
offset: int = None,
166167
sort: str = None,
@@ -187,8 +188,14 @@ def list_access_groups(self,
187188
multiple services by using one identifier. The header key must be set to
188189
Transaction-Id and the value is anything that you choose. If no transaction
189190
ID is passed in, then a random ID is generated.
190-
:param str iam_id: (optional) Return groups for member id (IBMid, Service
191-
Id or Profile Id).
191+
:param str iam_id: (optional) Return groups for member ID (IBMid, service
192+
ID or trusted profile ID).
193+
:param str membership_type: (optional) Membership type need to be specified
194+
along with iam_id and must be either `static`, `dynamic` or `all`. If
195+
membership type is `static`, members explicitly added to the group will be
196+
shown. If membership type is `dynamic`, members accessing the access group
197+
at the moment via dynamic rules will be shown. If membership type is `all`,
198+
both static and dynamic members will be shown.
192199
:param int limit: (optional) Return up to this limit of results where limit
193200
is between 0 and 100.
194201
:param int offset: (optional) The offset of the first result item to be
@@ -218,6 +225,7 @@ def list_access_groups(self,
218225
params = {
219226
'account_id': account_id,
220227
'iam_id': iam_id,
228+
'membership_type': membership_type,
221229
'limit': limit,
222230
'offset': offset,
223231
'sort': sort,
@@ -444,10 +452,11 @@ def is_member_of_access_group(self,
444452
"""
445453
Check membership in an access group.
446454
447-
This HEAD operation determines if a given `iam_id` is present in a group. No
448-
response body is returned with this request. If the membership exists, a `204 - No
449-
Content` status code is returned. If the membership or the group does not exist, a
450-
`404 - Not Found` status code is returned.
455+
This HEAD operation determines if a given `iam_id` is present in a group either
456+
explicitly or via dynamic rules. No response body is returned with this request.
457+
If the membership exists, a `204 - No Content` status code is returned. If the
458+
membership or the group does not exist, a `404 - Not Found` status code is
459+
returned.
451460
452461
:param str access_group_id: The access group identifier.
453462
:param str iam_id: The IAM identifier.
@@ -558,6 +567,7 @@ def list_access_group_members(self,
558567
access_group_id: str,
559568
*,
560569
transaction_id: str = None,
570+
membership_type: str = None,
561571
limit: int = None,
562572
offset: int = None,
563573
type: str = None,
@@ -580,13 +590,18 @@ def list_access_group_members(self,
580590
multiple services by using one identifier. The header key must be set to
581591
Transaction-Id and the value is anything that you choose. If no transaction
582592
ID is passed in, then a random ID is generated.
593+
:param str membership_type: (optional) Filters members by membership type.
594+
Membership type can be either `static`, `dynamic` or `all`. `static` lists
595+
those members explicitly added to the access group, `dynamic` lists those
596+
members part of access group via dynamic rules at the moment. `all` lists
597+
both static and dynamic members.
583598
:param int limit: (optional) Return up to this limit of results where limit
584599
is between 0 and 100.
585600
:param int offset: (optional) The offset of the first result item to be
586601
returned.
587602
:param str type: (optional) Filter the results by member type.
588603
:param bool verbose: (optional) Return user's email and name for each user
589-
id or the name for each service id or trusted profile.
604+
ID or the name for each service ID or trusted profile.
590605
:param str sort: (optional) If verbose is true, sort the results by id,
591606
name, or email.
592607
:param dict headers: A `dict` containing the request headers
@@ -605,6 +620,7 @@ def list_access_group_members(self,
605620
headers.update(sdk_headers)
606621

607622
params = {
623+
'membership_type': membership_type,
608624
'limit': limit,
609625
'offset': offset,
610626
'type': type,
@@ -641,7 +657,9 @@ def remove_member_from_access_group(self,
641657
642658
Remove one member from a group using this API. If the operation is successful,
643659
only a `204 - No Content` response with no body is returned. However, if any error
644-
occurs, the standard error format will be returned.
660+
occurs, the standard error format will be returned. Dynamic member cannot be
661+
deleted using this API. Dynamic rules needs to be adjusted to delete dynamic
662+
members.
645663
646664
:param str access_group_id: The access group identifier.
647665
:param str iam_id: The IAM identifier.
@@ -695,7 +713,8 @@ def remove_members_from_access_group(self,
695713
Remove multiple members from a group using this API. On a successful call, this
696714
API will always return 207. It is the caller's responsibility to iterate across
697715
the body to determine successful deletion of each member. This API request payload
698-
can delete up to 50 members per call.
716+
can delete up to 50 members per call. This API doesnt delete dynamic members
717+
accessing the access group via dynamic rules.
699718
700719
:param str access_group_id: The access group identifier.
701720
:param List[str] members: (optional) The `iam_id`s to remove from the
@@ -1437,7 +1456,7 @@ class AddGroupMembersRequestMembersItem():
14371456
"""
14381457
AddGroupMembersRequestMembersItem.
14391458
1440-
:attr str iam_id: The IBMid, Service Id or Profile Id of the member.
1459+
:attr str iam_id: The IBMid, service ID or trusted profile ID of the member.
14411460
:attr str type: The type of the member, must be either "user", "service" or
14421461
"trusted profile".
14431462
"""
@@ -1448,7 +1467,8 @@ def __init__(self,
14481467
"""
14491468
Initialize a AddGroupMembersRequestMembersItem object.
14501469
1451-
:param str iam_id: The IBMid, Service Id or Profile Id of the member.
1470+
:param str iam_id: The IBMid, service ID or trusted profile ID of the
1471+
member.
14521472
:param str type: The type of the member, must be either "user", "service"
14531473
or "trusted profile".
14541474
"""
@@ -2212,6 +2232,8 @@ class Group():
22122232
:attr str href: (optional) A url to the given group resource.
22132233
:attr bool is_federated: (optional) This is set to true if rules exist for the
22142234
group.
2235+
:attr str membership_type: (optional) Type of the membership. `static` or
2236+
`dynamic`.
22152237
"""
22162238

22172239
def __init__(self,
@@ -2225,7 +2247,8 @@ def __init__(self,
22252247
last_modified_at: datetime = None,
22262248
last_modified_by_id: str = None,
22272249
href: str = None,
2228-
is_federated: bool = None) -> None:
2250+
is_federated: bool = None,
2251+
membership_type: str = None) -> None:
22292252
"""
22302253
Initialize a Group object.
22312254
@@ -2237,6 +2260,8 @@ def __init__(self,
22372260
:param str href: (optional) A url to the given group resource.
22382261
:param bool is_federated: (optional) This is set to true if rules exist for
22392262
the group.
2263+
:param str membership_type: (optional) Type of the membership. `static` or
2264+
`dynamic`.
22402265
"""
22412266
self.id = id
22422267
self.name = name
@@ -2248,6 +2273,7 @@ def __init__(self,
22482273
self.last_modified_by_id = last_modified_by_id
22492274
self.href = href
22502275
self.is_federated = is_federated
2276+
self.membership_type = membership_type
22512277

22522278
@classmethod
22532279
def from_dict(cls, _dict: Dict) -> 'Group':
@@ -2273,6 +2299,8 @@ def from_dict(cls, _dict: Dict) -> 'Group':
22732299
args['href'] = _dict.get('href')
22742300
if 'is_federated' in _dict:
22752301
args['is_federated'] = _dict.get('is_federated')
2302+
if 'membership_type' in _dict:
2303+
args['membership_type'] = _dict.get('membership_type')
22762304
return cls(**args)
22772305

22782306
@classmethod
@@ -2303,6 +2331,8 @@ def to_dict(self) -> Dict:
23032331
_dict['href'] = self.href
23042332
if hasattr(self, 'is_federated') and self.is_federated is not None:
23052333
_dict['is_federated'] = self.is_federated
2334+
if hasattr(self, 'membership_type') and self.membership_type is not None:
2335+
_dict['membership_type'] = self.membership_type
23062336
return _dict
23072337

23082338
def _to_dict(self):
@@ -2615,7 +2645,10 @@ class ListGroupMembersResponseMember():
26152645
A single member of an access group in a list.
26162646
26172647
:attr str iam_id: (optional) The IBMid or Service Id of the member.
2618-
:attr str type: (optional) The member type - either `user` or `service`.
2648+
:attr str type: (optional) The member type - either `user`, `service` or
2649+
`profile`.
2650+
:attr str membership_type: (optional) The membership type - either `static` or
2651+
`dynamic`.
26192652
:attr str name: (optional) The user's or service id's name.
26202653
:attr str email: (optional) If the member type is user, this is the user's
26212654
email.
@@ -2632,6 +2665,7 @@ def __init__(self,
26322665
*,
26332666
iam_id: str = None,
26342667
type: str = None,
2668+
membership_type: str = None,
26352669
name: str = None,
26362670
email: str = None,
26372671
description: str = None,
@@ -2642,7 +2676,10 @@ def __init__(self,
26422676
Initialize a ListGroupMembersResponseMember object.
26432677
26442678
:param str iam_id: (optional) The IBMid or Service Id of the member.
2645-
:param str type: (optional) The member type - either `user` or `service`.
2679+
:param str type: (optional) The member type - either `user`, `service` or
2680+
`profile`.
2681+
:param str membership_type: (optional) The membership type - either
2682+
`static` or `dynamic`.
26462683
:param str name: (optional) The user's or service id's name.
26472684
:param str email: (optional) If the member type is user, this is the user's
26482685
email.
@@ -2656,6 +2693,7 @@ def __init__(self,
26562693
"""
26572694
self.iam_id = iam_id
26582695
self.type = type
2696+
self.membership_type = membership_type
26592697
self.name = name
26602698
self.email = email
26612699
self.description = description
@@ -2671,6 +2709,8 @@ def from_dict(cls, _dict: Dict) -> 'ListGroupMembersResponseMember':
26712709
args['iam_id'] = _dict.get('iam_id')
26722710
if 'type' in _dict:
26732711
args['type'] = _dict.get('type')
2712+
if 'membership_type' in _dict:
2713+
args['membership_type'] = _dict.get('membership_type')
26742714
if 'name' in _dict:
26752715
args['name'] = _dict.get('name')
26762716
if 'email' in _dict:
@@ -2697,6 +2737,8 @@ def to_dict(self) -> Dict:
26972737
_dict['iam_id'] = self.iam_id
26982738
if hasattr(self, 'type') and self.type is not None:
26992739
_dict['type'] = self.type
2740+
if hasattr(self, 'membership_type') and self.membership_type is not None:
2741+
_dict['membership_type'] = self.membership_type
27002742
if hasattr(self, 'name') and self.name is not None:
27012743
_dict['name'] = self.name
27022744
if hasattr(self, 'email') and self.email is not None:

ibm_platform_services/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
"""
22
Version of platform_services
33
"""
4-
__version__ = '0.22.9'
4+
__version__ = '0.23.0'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import sys
2020
import pkg_resources
2121

22-
__version__ = '0.22.9'
22+
__version__ = '0.23.0'
2323
PACKAGE_NAME = 'ibm_platform_services'
2424
PACKAGE_DESC = 'Python client library for IBM Cloud Platform Services'
2525

test/integration/test_iam_access_groups_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from ibm_platform_services.iam_access_groups_v2 import *
2929

3030
# Read config file
31-
configFile = 'iam_access_groups.env'
31+
configFile = 'iam_access_groups_v2.env'
3232

3333

3434
class TestIamAccessGroupsV2(unittest.TestCase):

0 commit comments

Comments
 (0)