<s> """<STR_LIT>""" <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> import json <EOL> from bigml . resourcehandler import ResourceHandler <EOL> from bigml . resourcehandler import ( check_resource_type , get_resource_type , <EOL> check_resource , <EOL> get_association_set_id , get_association_id ) <EOL> from bigml . constants import ( ASSOCIATION_SET_PATH , ASSOCIATION_PATH , <EOL> TINY_RESOURCE ) <EOL> class AssociationSetHandler ( ResourceHandler ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> """<STR_LIT>""" <EOL> self . association_set_url = self . url + ASSOCIATION_SET_PATH <EOL> def create_association_set ( self , association , input_data = None , <EOL> args = None , wait_time = <NUM_LIT:3> , retries = <NUM_LIT:10> ) : <EOL> """<STR_LIT>""" <EOL> association_id = None <EOL> resource_type = get_resource_type ( association ) <EOL> if resource_type == ASSOCIATION_PATH : <EOL> association_id = get_association_id ( association ) <EOL> check_resource ( association_id , <EOL> query_string = TINY_RESOURCE , <EOL> wait_time = wait_time , retries = retries , <EOL> raise_on_error = True , api = self ) <EOL> else : <EOL> raise Exception ( "<STR_LIT>" <EOL> "<STR_LIT>" % resource_type ) <EOL> if input_data is None : <EOL> input_data = { } <EOL> create_args = { } <EOL> if args is not None : <EOL> create_args . update ( args ) <EOL> create_args . update ( { <EOL> "<STR_LIT>" : input_data } ) <EOL> create_args . update ( { <EOL> "<STR_LIT>" : association_id } ) <EOL> body = json . dumps ( create_args ) <EOL> return self . _create ( self . association_set_url , body , <EOL> verify = self . verify ) <EOL> def get_association_set ( self , association_set ) : <EOL> """<STR_LIT>""" <EOL> check_resource_type ( association_set , ASSOCIATION_SET_PATH , <EOL> message = "<STR_LIT>" ) <EOL> association_set_id = get_association_set_id ( association_set ) <EOL> if association_set_id : <EOL> return self . _get ( "<STR_LIT>" % ( self . url , association_set_id ) ) <EOL> def list_association_sets ( self , query_string = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> return self . _list ( self . association_set_url , query_string ) <EOL> def update_association_set ( self , association_set , changes ) : <EOL> """<STR_LIT>""" <EOL> check_resource_type ( association_set , ASSOCIATION_SET_PATH , <EOL> message = "<STR_LIT>" ) <EOL> association_set_id = get_association_set_id ( association_set ) <EOL> if association_set_id : <EOL> body = json . dumps ( changes ) <EOL> return self . _update ( "<STR_LIT>" % ( self . url , association_set_id ) , body ) <EOL> def delete_association_set ( self , association_set ) : <EOL> """<STR_LIT>""" <EOL> check_resource_type ( association_set , ASSOCIATION_SET_PATH , <EOL> message = "<STR_LIT>" ) <EOL> association_set_id = get_association_set_id ( association_set ) <EOL> if association_set_id : <EOL> return self . _delete ( "<STR_LIT>" % ( self . url , association_set_id ) ) </s>
