<s> import logging <EOL> import base_behaviors <EOL> class SecretBehaviors ( base_behaviors . BaseBehaviors ) : <EOL> def __init__ ( self ) : <EOL> super ( SecretBehaviors , self ) . __init__ ( ) <EOL> self . LOG = logging . getLogger ( type ( self ) . __name__ ) <EOL> self . secret_hrefs_to_delete = [ ] <EOL> def update_secret ( self , <EOL> secret_href , <EOL> payload ) : <EOL> """<STR_LIT>""" <EOL> argv = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . add_auth_and_endpoint ( argv ) <EOL> argv . extend ( [ secret_href ] ) <EOL> argv . extend ( [ payload ] ) <EOL> stdout , stderr = self . issue_barbican_command ( argv ) <EOL> def delete_secret ( self , secret_href ) : <EOL> """<STR_LIT>""" <EOL> argv = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . add_auth_and_endpoint ( argv ) <EOL> argv . extend ( [ secret_href ] ) <EOL> stdout , stderr = self . issue_barbican_command ( argv ) <EOL> self . secret_hrefs_to_delete . remove ( secret_href ) <EOL> def store_secret ( self , payload = "<STR_LIT>" , store_argv = [ ] ) : <EOL> """<STR_LIT>""" <EOL> argv = [ '<STR_LIT>' , '<STR_LIT:store>' ] <EOL> self . add_auth_and_endpoint ( argv ) <EOL> argv . extend ( [ '<STR_LIT>' , payload ] ) <EOL> argv . extend ( store_argv ) <EOL> stdout , stderr = self . issue_barbican_command ( argv ) <EOL> secret_data = self . _prettytable_to_dict ( stdout ) <EOL> secret_href = secret_data [ '<STR_LIT>' ] <EOL> self . secret_hrefs_to_delete . append ( secret_href ) <EOL> return secret_href <EOL> def get_secret ( self , secret_href ) : <EOL> """<STR_LIT>""" <EOL> argv = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . add_auth_and_endpoint ( argv ) <EOL> argv . extend ( [ secret_href ] ) <EOL> stdout , stderr = self . issue_barbican_command ( argv ) <EOL> if '<STR_LIT>' in stderr : <EOL> return { } <EOL> secret_data = self . _prettytable_to_dict ( stdout ) <EOL> return secret_data <EOL> def get_secret_payload ( self , secret_href , raw = False ) : <EOL> """<STR_LIT>""" <EOL> argv = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . add_auth_and_endpoint ( argv ) <EOL> argv . extend ( [ secret_href ] ) <EOL> argv . extend ( [ '<STR_LIT>' ] ) <EOL> if raw : <EOL> argv . extend ( [ '<STR_LIT>' , '<STR_LIT:value>' ] ) <EOL> stdout , stderr = self . issue_barbican_command ( argv ) <EOL> if '<STR_LIT>' in stderr : <EOL> return { } <EOL> if raw : <EOL> secret = stdout . rstrip ( ) <EOL> else : <EOL> secret_data = self . _prettytable_to_dict ( stdout ) <EOL> secret = secret_data [ '<STR_LIT>' ] <EOL> return secret <EOL> def list_secrets ( self ) : <EOL> """<STR_LIT>""" <EOL> argv = [ '<STR_LIT>' , '<STR_LIT:list>' ] <EOL> self . add_auth_and_endpoint ( argv ) <EOL> stdout , stderr = self . issue_barbican_command ( argv ) <EOL> secret_list = self . _prettytable_to_list ( stdout ) <EOL> return secret_list <EOL> def delete_all_created_secrets ( self ) : <EOL> """<STR_LIT>""" <EOL> for href in self . secret_hrefs_to_delete : <EOL> self . delete_secret ( href ) </s>
