<s> """<STR_LIT>""" <EOL> import six <EOL> from openstackclient . common import command <EOL> from openstackclient . common import exceptions <EOL> from openstackclient . common import utils <EOL> from openstackclient . identity import common <EOL> class AuthorizeRequestToken ( command . ShowOne ) : <EOL> """<STR_LIT>""" <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( AuthorizeRequestToken , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> action = '<STR_LIT>' , <EOL> default = [ ] , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> identity_client = self . app . client_manager . identity <EOL> roles = [ ] <EOL> for role in parsed_args . role : <EOL> role_id = utils . find_resource ( <EOL> identity_client . roles , <EOL> role , <EOL> ) . id <EOL> roles . append ( role_id ) <EOL> verifier_pin = identity_client . oauth1 . request_tokens . authorize ( <EOL> parsed_args . request_key , <EOL> roles ) <EOL> return zip ( * sorted ( six . iteritems ( verifier_pin . _info ) ) ) <EOL> class CreateAccessToken ( command . ShowOne ) : <EOL> """<STR_LIT>""" <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( CreateAccessToken , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> token_client = self . app . client_manager . identity . oauth1 . access_tokens <EOL> access_token = token_client . create ( <EOL> parsed_args . consumer_key , parsed_args . consumer_secret , <EOL> parsed_args . request_key , parsed_args . request_secret , <EOL> parsed_args . verifier ) <EOL> return zip ( * sorted ( six . iteritems ( access_token . _info ) ) ) <EOL> class CreateRequestToken ( command . ShowOne ) : <EOL> """<STR_LIT>""" <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( CreateRequestToken , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> required = True <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> identity_client = self . app . client_manager . identity <EOL> if parsed_args . domain : <EOL> domain = common . find_domain ( identity_client , parsed_args . domain ) <EOL> project = utils . find_resource ( identity_client . projects , <EOL> parsed_args . project , <EOL> domain_id = domain . id ) <EOL> else : <EOL> project = utils . find_resource ( identity_client . projects , <EOL> parsed_args . project ) <EOL> token_client = identity_client . oauth1 . request_tokens <EOL> request_token = token_client . create ( <EOL> parsed_args . consumer_key , <EOL> parsed_args . consumer_secret , <EOL> project . id ) <EOL> return zip ( * sorted ( six . iteritems ( request_token . _info ) ) ) <EOL> class IssueToken ( command . ShowOne ) : <EOL> """<STR_LIT>""" <EOL> required_scope = False <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( IssueToken , self ) . get_parser ( prog_name ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> if not self . app . client_manager . auth_ref : <EOL> raise exceptions . AuthorizationFailure ( <EOL> "<STR_LIT>" ) <EOL> token = self . app . client_manager . auth_ref . service_catalog . get_token ( ) <EOL> if '<STR_LIT>' in token : <EOL> token [ '<STR_LIT>' ] = token . pop ( '<STR_LIT>' ) <EOL> return zip ( * sorted ( six . iteritems ( token ) ) ) <EOL> class RevokeToken ( command . Command ) : <EOL> """<STR_LIT>""" <EOL> def get_parser ( self , prog_name ) : <EOL> parser = super ( RevokeToken , self ) . get_parser ( prog_name ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> return parser <EOL> def take_action ( self , parsed_args ) : <EOL> identity_client = self . app . client_manager . identity <EOL> identity_client . tokens . revoke_token ( parsed_args . token ) </s>
