Add
Create a new general resource profile.
ResourceAdmin.add()
def add(self, resource: str, class_name: str, traits: dict = {}) -> Union[dict, bytes]:
📄 Description
Only a subset of available Segments and Traits are considered Stable. See Segments and Traits for more details.
Create a new general resource profile.
📥 Parameters
-
resource
The name of the general resource profile being created. -
class_name
The name of the class the general resource profile being created belongs to. -
traits
A dictionary of traits/attributes that should be given to the resource on creation. See Traits to see what all of the valid Resource Traits are.
📤 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
.AddOperationError
RaisesAddOperationError
when the general resource profile cannot be added because it already exists.SegmentTraitError
RaisesSegmentTraitError
when the dictionary of traits/attributes provided contains one or more unknown traits.
💻 Example
The following example creates a new general resource profile called TESTING
in the ELIJTEST
class with two traits/attributes as defined in the traits
dictionary.
Python Script
from pyracf import ResourceAdmin
resource_admin = ResourceAdmin()
traits = {
"base:universal_access": "None",
"base:owner": "eswift",
}
resource_admin.add("TESTING","ELIJTEST", traits=traits)
Security Result Dictionary as JSON
{
"securityResult": {
"resource": {
"name": "TESTING",
"class": "ELIJTEST",
"operation": "set",
"requestId": "ResourceRequest",
"commands": [
{
"safReturnCode": 0,
"returnCode": 0,
"reasonCode": 0,
"image": "RDEFINE ELIJTEST (TESTING) ",
"messages": [
"ICH10006I RACLISTED PROFILES FOR ELIJTEST WILL NOT REFLECT THE ADDITION(S) UNTIL A SETROPTS REFRESH IS ISSUED."
]
},
{
"safReturnCode": 0,
"returnCode": 0,
"reasonCode": 0,
"image": "RALTER ELIJTEST (TESTING) UACC (None) OWNER (eswift)",
"messages": [
"ICH11009I RACLISTED PROFILES FOR ELIJTEST WILL NOT REFLECT THE UPDATE(S) UNTIL A SETROPTS REFRESH IS ISSUED."
]
}
]
},
"returnCode": 0,
"reasonCode": 0,
"runningUserid": "testuser"
}
}