Profile Extract

Extract a data set profile’s profile data.

DataSetAdmin.extract()

def extract(
    self,
    data_set: str,
    segments: List[str] = [],
    volume: Union[str, None] = None,
    generic: bool = False,
    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 = data_set_admin.extract("ESWIFT.TEST.T1136242.P3020470", profile_only=True)
if profile["base"]["universalAccess"] == "read":
    # Do something

if data_set_admin.get_universal_access("ESWIFT.TEST.T1136242.P3020470") == "read":
  # Do something.

 

Extract a data set profile’s data.

📥 Parameters

  • data_set
    The data set profile 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.

  • volume
    A single volume name for this data set profile. This argument is optional. If generic=True is specified, volume is ignored.

  • generic
    A bool indicating whether to treat this profile as generic or not. This argument is optional and defaults to False.

  • 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 DataSetAdmin.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 the base segment of the data set profile ESWIFT.TEST.T1136242.P3020470. The base segment is extracted by default whether or not other segments are specified in the segments list.

Python REPL
>>> from pyracf import DataSetAdmin
>>> data_set_admin = DataSetAdmin()
>>> data_set_admin.extract("ESWIFT.TEST.T1136242.P3020470")
{"securityResult":{"dataSet":{"name":"ESWIFT.TEST.T1136242.P3020470","operation":"listdata","generic":"no","requestId":"DatasetRequest","commands":[{"safReturnCode":0,"returnCode":0,"reasonCode":0,"image":"LISTDSD  DATASET     ('ESWIFT.TEST.T1136242.P3020470')","profiles":[{"base":{"name":"eswift.test.t1136242.p3020470","level":0,"owner":"eswift","universalAccess":"read","warning":null,"erase":null,"auditing":{"failures":"read"},"notify":null,"yourAccess":"alter","creationGroup":"sys1","dataSetType":"non-vsam","volumes":["usrat2"],"installationData":null,"generic":false}}]}]},"returnCode":0,"reasonCode":0}}
Security Result Dictionary as JSON
{
  "securityResult": {
    "dataSet": {
      "name": "ESWIFT.TEST.T1136242.P3020470",
      "operation": "listdata",
      "generic": "no",
      "requestId": "DatasetRequest",
      "commands": [
        {
          "safReturnCode": 0,
          "returnCode": 0,
          "reasonCode": 0,
          "image": "LISTDSD  DATASET     ('ESWIFT.TEST.T1136242.P3020470')",
          "profiles": [
            {
              "base": {
                "name": "eswift.test.t1136242.p3020470",
                "level": 0,
                "owner": "eswift",
                "universalAccess": "read",
                "warning": null,
                "erase": null,
                "auditing": {
                  "failures": "read"
                },
                "notify": null,
                "yourAccess": "alter",
                "creationGroup": "sys1",
                "dataSetType": "non-vsam",
                "volumes": [
                  "usrat2"
                ],
                "installationData": null,
                "generic": false
              }
            }
          ]
        }
      ]
    },
    "returnCode": 0,
    "reasonCode": 0,
    "runningUserid": "testuser"
  }
}