Profile Extract
Extract a general resource profile’s profile data.
ResourceAdmin.extract()
def extract(
self,
data_set: str,
resource: str,
class_name: 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 = resource_admin.extract("TESTING","ELIJTEST", profile_only=True) if profile["base"]["universalAccess"] == "read": # Do something
✅
if resource_admin.get_universal_access("TESTING","ELIJTEST") == "read" # Do something.
Extract a general resource profile’s data.
📥 Parameters
-
resource
The name of the general resource profile being extracted. -
class_name
The name of the class the general resource profile being extracted belongs to. -
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 toTrue
, 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 theResourceAdmin.generate_requests_only
class attribute is set toTrue
.
❌ Raises
SecurityRequestError
RaisesSecurityRequestError
when the SAF Return Code of a Security Result is equal to4
.DownstreamFatalError
RaisesDownstreamFatalError
when the SAF Return Code of a Security Result is greater than4
.SegmentError
RaisesSegmentError
when the list of segments provided contains one or more unknown segments.
💻 Example
The following example extracts the base segment of the general resource profile TESTING
in the ELIJTEST
class. The base segment is extracted by default whether or not other segments are specified in the segments
list.
Python REPL
>>> from pyracf import ResourceAdmin
>>> resource_admin = ResourceAdmin()
>>> resource_admin.extract("TESTING","ELIJTEST")
{"securityResult":{"resource":{"name":"TESTING","class":"ELIJTEST","operation":"listdata","requestId":"ResourceRequest","commands":[{"safReturnCode":0,"returnCode":0,"reasonCode":0,"image":"RLIST ELIJTEST (TESTING) ","profiles":[{"base":{"class":"elijtest","name":"testing","level":0,"owner":"eswift","universalAccess":"read","yourAccess":"read","warning":null,"installationData":null,"applicationData":null,"auditing":{"failures":"read"},"notify":null,"generic":false}}]}]},"returnCode":0,"reasonCode":0}}
Security Result Dictionary as JSON
{
"securityResult": {
"resource": {
"name": "TESTING",
"class": "ELIJTEST",
"operation": "listdata",
"requestId": "ResourceRequest",
"commands": [
{
"safReturnCode": 0,
"returnCode": 0,
"reasonCode": 0,
"image": "RLIST ELIJTEST (TESTING) ",
"profiles": [
{
"base": {
"class": "elijtest",
"name": "testing",
"level": 0,
"owner": "eswift",
"universalAccess": "read",
"yourAccess": "read",
"warning": null,
"installationData": null,
"applicationData": null,
"auditing": {
"failures": "read"
},
"notify": null,
"generic": false
}
}
]
}
]
},
"returnCode": 0,
"reasonCode": 0,
"runningUserid": "testuser"
}
}