MCPcopy Index your code
hub / github.com/algorithmiaio/algorithmia-python / auth

Method auth

Algorithmia/CLI.py:13–34  ·  view source on GitHub ↗
(self, apiaddress, apikey="", cacert="", profile="default", bearer="")

Source from the content-addressed store, hash-verified

11 self.client = Algorithmia.client()
12 # algo auth
13 def auth(self, apiaddress, apikey="", cacert="", profile="default", bearer=""):
14
15 # store api key in local config file and read from it each time a client needs to be created
16 key = self.getconfigfile()
17 config = toml.load(key)
18
19 if ('profiles' in config.keys()):
20 if (profile in config['profiles'].keys()):
21 config['profiles'][profile]['api_key'] = apikey
22 config['profiles'][profile]['api_server'] = apiaddress
23 config['profiles'][profile]['ca_cert'] = cacert
24 config['profiles'][profile]['bearer_token'] = bearer
25
26 else:
27 config['profiles'][profile] = {'api_key':apikey,'api_server':apiaddress,'ca_cert':cacert,'bearer_token':bearer}
28 else:
29 config['profiles'] = {profile:{'api_key':apikey,'api_server':apiaddress,'ca_cert':cacert,'bearer_token':bearer }}
30
31 with open(key, "w") as key:
32 toml.dump(config,key)
33
34 self.ls(path = None,client = CLI().getClient(profile))
35
36 # algo run <algo> <args..> run the the specified algo
37 def runalgo(self, options, client):

Callers 5

mainFunction · 0.80
test_authMethod · 0.80
test_auth_certMethod · 0.80
test_auth_tokenMethod · 0.80
test_api_address_authMethod · 0.80

Calls 5

getconfigfileMethod · 0.95
lsMethod · 0.95
CLIClass · 0.85
loadMethod · 0.80
getClientMethod · 0.80

Tested by 4

test_authMethod · 0.64
test_auth_certMethod · 0.64
test_auth_tokenMethod · 0.64
test_api_address_authMethod · 0.64