示例#1
0
    def get_accounts_users(self,parameters={},offset=None,limit=None,order=None,include_sub_partners=None):
        url = "/accounts/users"
        headers = {'Authorization': self.token,
                   'Content-Type': "application/json", 'Accept': "application/vnd.mozy.bifrost+json;v=1"}
        query_string = ""
        # Add code here whether parameters is a empty dictionary
        for key,value in parameters.items():
            value = quote(str(value))
            query_string += "%s:\"%s\"" % (key,value)
        request_url = ('%s%s' % (self.base_url, url))
        query_string = str(query_string)
        if query_string != "":
            request_url = ('%s%s?q=%s' % (self.base_url, url, query_string))
        else:
            request_url = ('%s%s' % (self.base_url, url))
        print(request_url)
        if offset != None:
            request_url += "&offset=%s" % (offset)
        if limit != None:
            request_url += "&limit=%s" % (limit)
        if order != None:
            request_url += "&order=%s" % (order)
        if include_sub_partners != None and include_sub_partners == True:
            request_url += "&scope=include_sub_partners"
        response = RestfulHelper.send_get(request_url, headers)
        print(response.text)

        return response
示例#2
0
    def get_accounts_partner_id(self,id):
        url = "/accounts/partner/%s" % (id)
        headers = {'Authorization': self.token,
                   'Content-Type': "application/json", 'Accept': "application/vnd.mozy.bifrost+json;v=1"}
        request_url = ('%s%s' % (self.base_url, url))
        response = RestfulHelper.send_get(request_url,headers)

        return response
示例#3
0
 def get_auth_exchange(self):
     get_url = ""
     headers = {'Api-Key': self.api_key,
                'Content-Type': "application/json", 'Accept': "application/vnd.mozy.bifrost+json;v=1"}
     if self.x_mozy_partner != None:
         headers['X-MozyPartner'] = "%s" % self.x_mozy_partner
     if self.x_mozy_user != None:
         headers['X-MozyUser'] = self.x_mozy_user
     response = RestfulHelper.send_get(self.url,headers)
     hash = eval(response.text)
     print response.text
     print ('%s %s' % (hash['token_type'],hash['token']))
     return ('%s %s' % (hash['token_type'],hash['token']))
示例#4
0
    def get_accounts_licenses(self,parameters={}):
        url = "/accounts/licenses"
        headers = {'Authorization': self.token,
                   'Content-Type': "application/json", 'Accept': "application/vnd.mozy.bifrost+json;v=1"}
        query_string = ""
        if parameters is not None:
            query_string = urlencode(parameters)
        if query_string != "":
            request_url = ('%s%s?%s' % (self.base_url, url, query_string))
        else:
            request_url = ('%s%s' % (self.base_url, url))

        print(request_url)
        response = RestfulHelper.send_get(request_url, headers)
        print(response.text)

        return response
示例#5
0
    def get_accounts_partners(self,parameters={}):
        url = "/accounts/partners"
        headers = {'Authorization': self.token,
                   'Content-Type': "application/json", 'Accept': "application/vnd.mozy.bifrost+json;v=1"}
        query_string = ""
        # Add code here whether parameters is a empty dictionary
        for key,value in parameters.items():
            query_string += key + ':' + value
        request_url = ('%s%s' % (self.base_url, url))
        query_string = str(query_string)
        if query_string != "":
            query_string = quote(query_string)
            request_url = ('%s%s?q=%s' % (self.base_url, url, query_string))
        else:
            request_url = ('%s%s' % (self.base_url, url))
        print(request_url)
        response = RestfulHelper.send_get(request_url, headers)
        print(response.text)

        return response