Profile Extract

Extract a group’s profile data.

GroupAdmin.extract()

def extract(
    self, group: str, segments: List[str] = [], profile_only: bool = False
) -> Union[dict, bytes]:

📄 Description

 

Profile data extracted for experimental Segments and Traits are considered Experimental. See Segments and Traits for more details.

 

Note that it is recommended to extract profile data using the provided Getter functions in most cases.

 

profile = group_admin.extract("testgrp0", segments=["omvs"], profile_only=True)
if profile["omvs"]["gid"] == 4545:
    # Do something

if resource_admin.get_omvs_gid("testgrp0") == 4545:
  # Do something.

 

Extract a group’s profile data.

📥 Parameters

  • group
    The group to extract segment data from.

  • segments
    A list of additional segments to extract. The base segment is extracted by default, but providing one or more additional segment keys for other segments in the form of a list will result in those segments being extracted as well.

  • profile_only
    When set to True, only the extracted profile will be returned instead of returning the entire Security Result dictionary.

📤 Returns

  • Union[dict, bytes]
    Returns a Security Result dictionary or Security Request XML bytes if the GroupAdmin.generate_requests_only class attribute is set to True.

❌ Raises

  • SecurityRequestError
    Raises SecurityRequestError when the SAF Return Code of a Security Result is equal to 4.
  • DownstreamFatalError
    Raises DownstreamFatalError when the SAF Return Code of a Security Result is greater than 4.
  • SegmentError
    Raises SegmentError when the list of segments provided contains one or more unknown segments.

💻 Example

The following example extracts group testgrp0’s base segment and OMVS segment. The base segment is extracted by default and the OMVS segment is extracted because omvs is provided in the segments list. All other segments that are not specified are not extracted.

Python REPL
>>> from pyracf import GroupAdmin
>>> group_admin = GroupAdmin()
>>> group_admin.extract("testgrp0", segments=["omvs"])
{'securityResult': {'group': {'name': 'TESTGRP0', 'operation': 'listdata', 'requestId': 'GroupRequest', 'commands': [{'safReturnCode': 0, 'returnCode': 0, 'reasonCode': 0, 'image': 'LISTGRP TESTGRP0  OMVS    ', 'profiles': [{'base': {'name': 'testgrp0', 'superiorGroup': 'sys1', 'owner': 'eswift', 'created': '5/30/2023', 'installationData': None, 'modelDataSet': None, 'terminalUniversalAccess': True, 'subgroups': [], 'users': [{'userid': 'eswift', 'access': 'use', 'accessCount': 0, 'universalAccess': None, 'connectAttributes': ['special'], 'revokeDate': None, 'resumeDate': None}, {'userid': 'leonard', 'access': 'use', 'accessCount': 0, 'universalAccess': None, 'connectAttributes': ['operations'], 'revokeDate': None, 'resumeDate': None}]}, 'omvs': {'gid': 4545}}]}]}, 'returnCode': 0, 'reasonCode': 0, 'runningUserid': 'testuser'}}
Security Result Dictionary as JSON
{
  "securityResult": {
    "group": {
      "name": "TESTGRP0",
      "operation": "listdata",
      "requestId": "GroupRequest",
      "commands": [
        {
          "safReturnCode": 0,
          "returnCode": 0,
          "reasonCode": 0,
          "image": "LISTGRP TESTGRP0  OMVS    ",
          "profiles": [
            {
              "base": {
                "name": "testgrp0",
                "superiorGroup": "sys1",
                "owner": "eswift",
                "created": "5/30/2023",
                "installationData": null,
                "modelDataSet": null,
                "terminalUniversalAccess": true,
                "subgroups": [],
                "users": [
                  {
                    "userid": "eswift",
                    "access": "use",
                    "accessCount": 0,
                    "universalAccess": null,
                    "connectAttributes": [
                      "special"
                    ],
                    "revokeDate": null,
                    "resumeDate": null
                  },
                  {
                    "userid": "leonard",
                    "access": "use",
                    "accessCount": 0,
                    "universalAccess": null,
                    "connectAttributes": [
                      "operations"
                    ],
                    "revokeDate": null,
                    "resumeDate": null
                  }
                ]
              },
              "omvs": {
                "gid": 4545
              }
            }
          ]
        }
      ]
    },
    "returnCode": 0,
    "reasonCode": 0,
    "runningUserid": "testuser"
  }
}