def add_identity_parser(subparsers, parent_parser):
    """Creates the arg parsers needed for the identity command and
    its subcommands.
    """
    # identity
    parser = subparsers.add_parser(
        'identity',
        help='Works with optional roles, policies, and permissions',
        description='Provides subcommands to work with roles and policies.')

    identity_parsers = parser.add_subparsers(
        title="subcommands",
        dest="subcommand")

    identity_parsers.required = True

    # policy
    policy_parser = identity_parsers.add_parser(
        'policy',
        help='Provides subcommands to display existing policies and create '
        'new policies',
        description='Provides subcommands to list the current policies '
        'stored in state and to create new policies.')

    policy_parsers = policy_parser.add_subparsers(
        title='policy',
        dest='policy_cmd')

    policy_parsers.required = True

    # policy create
    create_parser = policy_parsers.add_parser(
        'create',
        help='Creates batches of sawtooth-identity transactions for setting a '
        'policy',
        description='Creates a policy that can be set to a role or changes a '
        'policy without resetting the role.')

    create_parser.add_argument(
        '-k', '--key',
        type=str,
        help='specify the signing key for the resulting batches')

    create_target_group = create_parser.add_mutually_exclusive_group()

    create_target_group.add_argument(
        '-o', '--output',
        type=str,
        help='specify the output filename for the resulting batches')

    create_target_group.add_argument(
        '--url',
        type=str,
        help="identify the URL of a validator's REST API",
        default='http://localhost:8008')

    create_parser.add_argument(
        '--wait',
        type=int,
        default=15,
        help="set time, in seconds, to wait for the policy to commit when "
             "submitting to the REST API.")

    create_parser.add_argument(
        'name',
        type=str,
        help='name of the new policy')

    create_parser.add_argument(
        'rule',
        type=str,
        nargs="+",
        help='rule with the format "PERMIT_KEY <key>" or "DENY_KEY <key> '
        '(multiple "rule" arguments can be specified)')

    # policy list
    list_parser = policy_parsers.add_parser(
        'list',
        help='Lists the current policies',
        description='Lists the policies that are currently set in state.')

    list_parser.add_argument(
        '--url',
        type=str,
        help="identify the URL of a validator's REST API",
        default='http://localhost:8008')

    list_parser.add_argument(
        '--format',
        default='default',
        choices=['default', 'csv', 'json', 'yaml'],
        help='choose the output format')

    # role
    role_parser = identity_parsers.add_parser(
        'role',
        help='Provides subcommands to display existing roles and create '
        'new roles',
        description='Provides subcommands to list the current roles '
        'stored in state and to create new roles.')

    role_parsers = role_parser.add_subparsers(
        title='role',
        dest='role_cmd')

    role_parsers.required = True

    # role create
    create_parser = role_parsers.add_parser(
        'create',
        help='Creates a new role that can be used to enforce permissions',
        description='Creates a new role that can be used to enforce '
        'permissions.')

    create_parser.add_argument(
        '-k', '--key',
        type=str,
        help='specify the signing key for the resulting batches')

    create_parser.add_argument(
        '--wait',
        type=int,
        default=15,
        help='set time, in seconds, to wait for a role to commit '
        'when submitting to  the REST API.')

    create_target_group = create_parser.add_mutually_exclusive_group()

    create_target_group.add_argument(
        '-o', '--output',
        type=str,
        help='specify the output filename for the resulting batches')

    create_target_group.add_argument(
        '--url',
        type=str,
        help="the URL of a validator's REST API",
        default='http://localhost:8008')

    create_parser.add_argument(
        'name',
        type=str,
        help='name of the role')

    create_parser.add_argument(
        'policy',
        type=str,
        help='identify policy that role will be restricted to')

    # role list
    list_parser = role_parsers.add_parser(
        'list',
        help='Lists the current keys and values of roles',
        description='Displays the roles that are currently set in state.')

    list_parser.add_argument(
        '--url',
        type=str,
        help="identify the URL of a validator's REST API",
        default='http://localhost:8008')

    list_parser.add_argument(
        '--format',
        default='default',
        choices=['default', 'csv', 'json', 'yaml'],
        help='choose the output format')
def add_identity_parser ( subparsers , parent_parser ) : parser = subparsers . add_parser ( 'identity' , help = 'Works with optional roles, policies, and permissions' , description = 'Provides subcommands to work with roles and policies.' ) identity_parsers = parser . add_subparsers ( title = "subcommands" , dest = "subcommand" ) identity_parsers . required = True policy_parser = identity_parsers . add_parser ( 'policy' , help = 'Provides subcommands to display existing policies and create ' 'new policies' , description = 'Provides subcommands to list the current policies ' 'stored in state and to create new policies.' ) policy_parsers = policy_parser . add_subparsers ( title = 'policy' , dest = 'policy_cmd' ) policy_parsers . required = True create_parser = policy_parsers . add_parser ( 'create' , help = 'Creates batches of sawtooth-identity transactions for setting a ' 'policy' , description = 'Creates a policy that can be set to a role or changes a ' 'policy without resetting the role.' ) create_parser . add_argument ( '-k' , '--key' , type = str , help = 'specify the signing key for the resulting batches' ) create_target_group = create_parser . add_mutually_exclusive_group ( ) create_target_group . add_argument ( '-o' , '--output' , type = str , help = 'specify the output filename for the resulting batches' ) create_target_group . add_argument ( '--url' , type = str , help = "identify the URL of a validator's REST API" , default = 'http://localhost:8008' ) create_parser . add_argument ( '--wait' , type = int , default = 15 , help = "set time, in seconds, to wait for the policy to commit when " "submitting to the REST API." ) create_parser . add_argument ( 'name' , type = str , help = 'name of the new policy' ) create_parser . add_argument ( 'rule' , type = str , nargs = "+" , help = 'rule with the format "PERMIT_KEY <key>" or "DENY_KEY <key> ' '(multiple "rule" arguments can be specified)' ) list_parser = policy_parsers . add_parser ( 'list' , help = 'Lists the current policies' , description = 'Lists the policies that are currently set in state.' ) list_parser . add_argument ( '--url' , type = str , help = "identify the URL of a validator's REST API" , default = 'http://localhost:8008' ) list_parser . add_argument ( '--format' , default = 'default' , choices = [ 'default' , 'csv' , 'json' , 'yaml' ] , help = 'choose the output format' ) role_parser = identity_parsers . add_parser ( 'role' , help = 'Provides subcommands to display existing roles and create ' 'new roles' , description = 'Provides subcommands to list the current roles ' 'stored in state and to create new roles.' ) role_parsers = role_parser . add_subparsers ( title = 'role' , dest = 'role_cmd' ) role_parsers . required = True create_parser = role_parsers . add_parser ( 'create' , help = 'Creates a new role that can be used to enforce permissions' , description = 'Creates a new role that can be used to enforce ' 'permissions.' ) create_parser . add_argument ( '-k' , '--key' , type = str , help = 'specify the signing key for the resulting batches' ) create_parser . add_argument ( '--wait' , type = int , default = 15 , help = 'set time, in seconds, to wait for a role to commit ' 'when submitting to  the REST API.' ) create_target_group = create_parser . add_mutually_exclusive_group ( ) create_target_group . add_argument ( '-o' , '--output' , type = str , help = 'specify the output filename for the resulting batches' ) create_target_group . add_argument ( '--url' , type = str , help = "the URL of a validator's REST API" , default = 'http://localhost:8008' ) create_parser . add_argument ( 'name' , type = str , help = 'name of the role' ) create_parser . add_argument ( 'policy' , type = str , help = 'identify policy that role will be restricted to' ) list_parser = role_parsers . add_parser ( 'list' , help = 'Lists the current keys and values of roles' , description = 'Displays the roles that are currently set in state.' ) list_parser . add_argument ( '--url' , type = str , help = "identify the URL of a validator's REST API" , default = 'http://localhost:8008' ) list_parser . add_argument ( '--format' , default = 'default' , choices = [ 'default' , 'csv' , 'json' , 'yaml' ] , help = 'choose the output format' )
Creates the arg parsers needed for the identity command and
    its subcommands.