Пример #1
0
    def fetch_travis_token(url, github_token):
        extra_headers = {
            'accept': 'application/vnd.travis-ci.2+json',
            'user-agent': 'MyClient / 1.0.0',
            'content-type': 'application/json'
        }

        cp = ConnectionProperties(api_url='api.%s' % url, secure_http=True, extra_headers=extra_headers)
        client = Client(connection_properties=cp)
        status, result = client.post('/auth/github', {'github_token': github_token})

        if status != 200:
            print(client.headers)
            raise Exception("Unable to fetch Travis token: %s -> %s" % (status, result))

        return result['access_token']
Пример #2
0
 def __init__(self, *args, **kwargs):
     props = ConnectionProperties(
         api_url='graph.facebook.com',
         secure_http=True,
     )
     self.setClient(Client(*args, **kwargs))
     self.setConnectionProperties(props)
Пример #3
0
 def __init__(self, *args, **kwargs):
     props = ConnectionProperties(
         api_url='na1.salesforce.com',
         secure_http=True,
     )
     self.setClient(Client(*args, **kwargs))
     self.setConnectionProperties(props)
Пример #4
0
 def __init__(self, *args, **kwargs):
     props = ConnectionProperties(
         api_url='api.openweathermap.org',
         secure_http=False,
     )
     self.setClient(Client(*args, **kwargs))
     self.setConnectionProperties(props)
Пример #5
0
 def __init__(self, token, accept='application/json', *args, **kwargs):
     extra_headers = dict(Accept=accept,
                          Authorization='Bearer {0}'.format(token))
     props = ConnectionProperties(api_url='ci.appveyor.com',
                                  secure_http=True,
                                  extra_headers=extra_headers)
     self.setClient(Client(*args, **kwargs))
     self.setConnectionProperties(props)
Пример #6
0
 def __init__(self, *args, **kwargs):
     props = ConnectionProperties(
         api_url='search.maven.org',
         url_prefix='/solrsearch',
         secure_http=True,
     )
     self.setClient(Client(*args, **kwargs))
     self.setConnectionProperties(props)
Пример #7
0
 def __init__(self, token=None, *args, **kwargs):
     props = ConnectionProperties(
         api_url='api.bitbucket.org',
         url_prefix='/2.0',
         secure_http=True,
         extra_headers=self.generateAuthHeader(token),
     )
     self.setClient(Client(*args, **kwargs))
     self.setConnectionProperties(props)
Пример #8
0
 def __init__(self, token=None, *args, **kwargs):
     props = ConnectionProperties(
         api_url='api.digitalocean.com',
         url_prefix='/v2',
         secure_http=True,
         extra_headers={'authorization': self.generateAuthHeader(token)},
     )
     self.setClient(Client(*args, **kwargs))
     self.setConnectionProperties(props)
Пример #9
0
    def __init__(self,
                 username=None,
                 password=None,
                 token=None,
                 *args,
                 **kwargs):
        extraHeaders = {'accept': 'application/vnd.github.v3+json'}
        auth = self.generateAuthHeader(username, password, token)
        if auth is not None:
            extraHeaders['authorization'] = auth
        props = ConnectionProperties(api_url=kwargs.pop(
            'api_url', 'api.github.com'),
                                     secure_http=True,
                                     extra_headers=extraHeaders)

        self.setClient(Client(*args, **kwargs))
        self.setConnectionProperties(props)