Пример #1
0
	def __init__(self, options=None, **args):
		"""Create Mozu Client object

		Usage::
			>>> import mozurestsdk
			>>> client = mozurestsdk.MozuClient(applicationKey='appKey', shareSecret='sharedsecret')
			>>> or
			>>> client = mozurestsdk.MozuClient(configFile='path to config')
		"""

		args = util.merge_dict(options or {}, args);
		
		configFile = args.get("config", None);
		if (configFile != None):
			args = util.merge_dict(util.readConfigFile(configFile) or {}, args)
			

		self.verifySSLCert = args.get("verifySSLCert", None);
		if ( self.verifySSLCert is not None):
			self.verifySSLCert = self.verifySSLCert == "True";
		#else:
		#	self.verifySSLCert = True;

		self.baseAuthUrl = args.get("baseAuthUrl", __baseUrl__);
		authScheme = urlparse(self.baseAuthUrl).scheme;
		if (not authScheme):
			self.__scheme = authScheme;
		self.basePCIUrl = args.get("basePCIUrl", __basePciUrl__);
		
		self.appAuth = appauthenticator.configure(**args);
		#self.isAuthenticated = False;
		tenantId = args.get("tenantId", None);
		if (tenantId is not None):
			self.__apiContext = ApiContext(**args);
def default():
	global __appauthenticator__
	if (__appauthenticator__ is None):
		configFile = os.getenv("config", None);
		args = {};
		if (configFile is not None):
			args = util.merge_dict(util.readConfigFile(configFile) or {}, args)

		applicationKey = args.get("applicationKey", os.getenv("applicationKey", None));
		sharedSecret = args.get("sharedSecret", os.getenv("sharedSecret", None));
		baseAuthUrl = args.get("baseAuthUrl", os.getenv("baseAuthUrl",__baseUrl__));
		__appauthenticator__ = AppAuthenticator(applicationKey, sharedSecret, baseAuthUrl, verifySSLCert);
	return __appauthenticator__;
def set_config(options=None, **args):
	global __appauthenticator__;
	args = util.merge_dict(options or {}, args);
	if (__appauthenticator__ is None):
		configFile = args.get("config", None);
		args = util.merge_dict(util.readConfigFile(configFile) or {}, args);

	applicationKey = args.get("applicationKey", None);
	sharedSecret = args.get("sharedSecret", None);
	baseAuthUrl = args.get("baseAuthUrl", __baseUrl__);
	verifySSLCert = args.get("verifySSLCert", None);
	if (verifySSLCert is not None):
		verifySSLCert = verifySSLCert == "True";
	__appauthenticator__ = AppAuthenticator(applicationKey, sharedSecret, baseAuthUrl, verifySSLCert);
	return __appauthenticator__;
	def setUp(self):
		self.config = util.readConfigFile("c:\projects\mozuconfig.txt");
		mozuclient.configure(config="c:\projects\mozuconfig.txt");