Add

Create a new group.

GroupAdmin.add()

def add(self, group: 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 group.

📥 Parameters

  • group
    The group being created.

  • traits
    A dictionary of traits/attributes that should be given to the group on creation. See Traits to see what all of the valid Group Traits are.

📤 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.
  • AddOperationError
    Raises AddOperationError when the group cannot be added because it already exists.
  • SegmentTraitError
    Raises SegmentTraitError when the dictionary of traits/attributes provided contains one or more unknown traits.

💻 Example

The following example creates a new group called testgrp0 with two traits/attributes as defined in the traits dictionary.

Python Script
from pyracf import GroupAdmin
group_admin = GroupAdmin()

traits = {
    "ovms:gid": 1024,
    "ovm:gid": 512,
}

group_admin.add("testgrp0", traits=traits)
Security Result Dictionary as JSON
{
  "securityResult": {
    "group": {
      "name": "TESTGRP0",
      "operation": "set",
      "requestId": "GroupRequest",
      "commands": [
        {
          "safReturnCode": 0,
          "returnCode": 0,
          "reasonCode": 0,
          "image": "ADDGROUP TESTGRP0 "
        },
        {
          "safReturnCode": 0,
          "returnCode": 0,
          "reasonCode": 0,
          "image": "ALTGROUP TESTGRP0  OMVS     (GID         (1024)) OVM      (GID         (512))"
        }
      ]
    },
    "returnCode": 0,
    "reasonCode": 0,
    "runningUserid": "testuser"
  }
}