<s> import os <EOL> import logging <EOL> import six <EOL> from st2client import models <EOL> from st2client . models . core import ResourceManager <EOL> from st2client . models . core import ActionAliasResourceManager <EOL> from st2client . models . core import LiveActionResourceManager <EOL> from st2client . models . core import TriggerInstanceResourceManager <EOL> LOG = logging . getLogger ( __name__ ) <EOL> DEFAULT_API_PORT = <NUM_LIT> <EOL> DEFAULT_AUTH_PORT = <NUM_LIT> <EOL> DEFAULT_BASE_URL = '<STR_LIT>' <EOL> DEFAULT_API_VERSION = '<STR_LIT>' <EOL> class Client ( object ) : <EOL> def __init__ ( self , base_url = None , auth_url = None , api_url = None , api_version = None , cacert = None , <EOL> debug = False , token = None ) : <EOL> self . endpoints = dict ( ) <EOL> if base_url : <EOL> self . endpoints [ '<STR_LIT>' ] = base_url <EOL> else : <EOL> self . endpoints [ '<STR_LIT>' ] = os . environ . get ( '<STR_LIT>' , DEFAULT_BASE_URL ) <EOL> api_version = api_version or os . environ . get ( '<STR_LIT>' , DEFAULT_API_VERSION ) <EOL> if api_url : <EOL> self . endpoints [ '<STR_LIT>' ] = api_url <EOL> else : <EOL> self . endpoints [ '<STR_LIT>' ] = os . environ . get ( <EOL> '<STR_LIT>' , '<STR_LIT>' % ( self . endpoints [ '<STR_LIT>' ] , DEFAULT_API_PORT , api_version ) ) <EOL> if auth_url : <EOL> self . endpoints [ '<STR_LIT>' ] = auth_url <EOL> else : <EOL> self . endpoints [ '<STR_LIT>' ] = os . environ . get ( <EOL> '<STR_LIT>' , '<STR_LIT>' % ( self . endpoints [ '<STR_LIT>' ] , DEFAULT_AUTH_PORT ) ) <EOL> if cacert is not None : <EOL> self . cacert = cacert <EOL> else : <EOL> self . cacert = os . environ . get ( '<STR_LIT>' , None ) <EOL> is_cacert_string = isinstance ( self . cacert , six . string_types ) <EOL> if ( self . cacert and is_cacert_string and not os . path . isfile ( self . cacert ) ) : <EOL> raise ValueError ( '<STR_LIT>' % ( self . cacert ) ) <EOL> self . debug = debug <EOL> if token : <EOL> os . environ [ '<STR_LIT>' ] = token <EOL> self . token = token <EOL> self . managers = dict ( ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Token , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . RunnerType , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Action , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ActionAliasResourceManager ( <EOL> models . ActionAlias , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . ApiKey , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = LiveActionResourceManager ( <EOL> models . LiveAction , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Policy , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . PolicyType , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Rule , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Sensor , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . TriggerType , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Trigger , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = TriggerInstanceResourceManager ( <EOL> models . TriggerInstance , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . KeyValuePair , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Webhook , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . Trace , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> self . managers [ '<STR_LIT>' ] = ResourceManager ( <EOL> models . RuleEnforcement , self . endpoints [ '<STR_LIT>' ] , cacert = self . cacert , debug = self . debug ) <EOL> @ property <EOL> def actions ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def apikeys ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def keys ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def liveactions ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def policies ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def policytypes ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def rules ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def runners ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def sensors ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def tokens ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def triggertypes ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def triggerinstances ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def trace ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] <EOL> @ property <EOL> def ruleenforcements ( self ) : <EOL> return self . managers [ '<STR_LIT>' ] </s>
