def __init__(self, parent, application_id, object_id=None): self.parent = parent self.object_id = object_id self.application_id = http.quote_any(application_id) if self.object_id: self.object_id = http.quote_any(self.object_id)
def __init__(self, subdomain, username=None, password=None, access_token=None): """ Create a Zendesk service. :var subdomain: The account-specific part of the Zendesk domain, for instance use `mycompany` if your Zendesk domain is `mycompany.zendesk.com`. :vartype subdomain: str :var username: The email of the authenticated agent. Use `[email protected]/token` for token-based authentication. :vartype username: str :var password: The password of the authenticated agent, or an API token if using token-based authentication. :vartype password: str :var access_token: An OAuth Access token. Username and password are not required if the OAuth Access token is provided. :vartype access_token: str """ tmpl = '{0}.zendesk.com/api/v2' self.apiroot = http.quote_any(tmpl.format(port.to_u(subdomain))) self.apiroot = 'https://' + self.apiroot if access_token: self.access_token = access_token self.add_filter(self.add_authorization) else: self.add_filter(auth.BasicAuth(username, password)) self.add_filter(self.use_json)
def __init__(self, subdomain, api_key, api_secret=None, access_token=None, access_token_secret=None): """ Create a Desk service. :var subdomain: The account-specific part of the Desk domain, for instance use `mycompany` if your Desk domain is `mycompany.desk.com`. :vartype subdomain: str :var api_key: The API key. :vartype api_key: str :var api_secret: API secret. :vartype api_secret: str :var access_token: OAuth 1.0a access token. :vartype access_token: str :var access_token_secret: OAuth 1.0a access token secret. requests. :vartype access_token_secret: str """ tmpl = '{0}.desk.com/api/v1' self.apiroot = http.quote_any(tmpl.format(port.to_u(subdomain))) self.apiroot = 'https://' + self.apiroot self.oauth = auth.OAuth(access_token, access_token_secret, api_key, api_secret) self.add_filter(self.use_json) # authenticate has to be the last filter, because anything that # modifies the request after it's signed will make the signature # invalid! self.add_filter(self.authenticate)
def __init__(self, api_key): """ Create a Mailchimp service. :var api_key: The API key including the region, for instance `8ac789caf98879caf897a678fa76daf-us2`. :vartype api_key: str """ self.api_key, dc = port.to_u(api_key).split('-') tmpl = '{0}.api.mailchimp.com/1.3/' self.apiroot = http.quote_any(tmpl.format(dc)) self.apiroot = 'https://' + self.apiroot self.add_filter(self.add_api_root) self.add_filter(self.add_params)
def __init__(self, subdomain, api_key, api_secret=None, access_token=None, access_token_secret=None): """ Create a UserVoice service. :var subdomain: The account-specific part of the UserVoice domain, for instance use `mycompany` if your UserVoice domain is `mycompany.uservoice.com`. :vartype subdomain: str :var api_key: The API key. :vartype api_key: str :var api_secret: Optional API secret. If you leave this as None, all requests will be made as unauthenticated requests. :vartype api_secret: str or None :var access_token: Optional OAuth 1.0a access token. If you leave this as None, all requests be made as unauthenticated requests. :vartype access_token: str or None :var access_token_secret: Optional OAuth 1.0a access token secret. If you leave this as None, all requests be made as unauthenticated requests. :vartype access_token_secret: str or None """ self.api_key = api_key self.oauth = None if api_secret and access_token and access_token_secret: self.oauth = auth.OAuth1a(access_token, access_token_secret, api_key, api_secret) tmpl = '{0}.uservoice.com/api/v1' self.apiroot = http.quote_any(tmpl.format(port.to_u(subdomain))) self.apiroot = 'http://' + self.apiroot self.add_filter(self.use_json) self.add_filter(self.serialize_flatten) # authenticate has to be the last filter, because anything that # modifies the request after it's signed will make the signature # invalid! self.add_filter(self.authenticate)
def urlmetrics(self, urls, cols): """ Fetch URL metrics for one or more URLs. :var urls: The URLs you're interested in. :vartype urls: str or list of str :var cols: The sum of column constants for metrics you want to have fetched, taken from `libsaas.services.mozscape.constants`. """ if isinstance(urls, list): return self.list_urlmetrics(urls, str(cols)) uri = '/url-metrics/{0}/'.format(http.quote_any(urls)) request = http.Request('GET', uri, {'Cols': str(cols)}) return request, parsers.parse_json
def __init__(self, subdomain, api_key): """ Create a CartoDB service. :var subdomain: The account-specific part of the CartoDB domain, for instance use `mycompany` if your CartpDB domain is `mycompany.cartodb.com`. :vartype subdomain: str :var api_key: The API key. :vartype api_key: str """ tmpl = '{0}.cartodb.com/api' self.apiroot = http.quote_any(tmpl.format(port.to_u(subdomain))) self.apiroot = 'https://' + self.apiroot self.api_key = api_key self.add_filter(self.add_api_key)
def __init__(self, subdomain, username, password): """ Create a Zendesk service. :var subdomain: The account-specific part of the Zendesk domain, for instance use `mycompany` if your Zendesk domain is `mycompany.zendesk.com`. :vartype subdomain: str :var username: The email of the authenticated agent. :vartype username: str :var password: The password of the authenticated agent. :vartype password: str """ tmpl = '{0}.zendesk.com/api/v2' self.apiroot = http.quote_any(tmpl.format(port.to_u(subdomain))) self.apiroot = 'https://' + self.apiroot self.add_filter(auth.BasicAuth(username, password)) self.add_filter(self.use_json)
def __init__(self, subdomain, api_key, api_secret=None, access_token=None, access_token_secret=None): """ Create a Desk service. :var subdomain: The account-specific part of the Desk domain, for instance use `mycompany` if your Desk domain is `mycompany.desk.com`, or the full domain if using Desk whitelabel, for instance `support.mycompany.com`. If the parameter contains a dot, it is treated as a full domain, otherwise as a subdomain. :vartype subdomain: str :var api_key: The API key. :vartype api_key: str :var api_secret: API secret. :vartype api_secret: str :var access_token: OAuth 1.0a access token. :vartype access_token: str :var access_token_secret: OAuth 1.0a access token secret. requests. :vartype access_token_secret: str """ tmpl = '{0}/api/v1' if '.' not in subdomain: subdomain += '.desk.com' self.apiroot = http.quote_any(tmpl.format(port.to_u(subdomain))) self.apiroot = 'https://' + self.apiroot self.oauth = auth.OAuth(access_token, access_token_secret, api_key, api_secret) self.add_filter(self.use_json) # authenticate has to be the last filter, because anything that # modifies the request after it's signed will make the signature # invalid! self.add_filter(self.authenticate)
def __init__(self, subdomain, api_key, api_secret=None, access_token=None, access_token_secret=None): """ Create a Desk service. :var subdomain: The account-specific part of the Desk domain, for instance use `mycompany` if your Desk domain is `mycompany.desk.com`, or the full domain if using Desk whitelabel, for instance `support.mycompany.com`. If the parameter contains a dot, it is treated as a full domain, otherwise as a subdomain. :vartype subdomain: str :var api_key: The API key. :vartype api_key: str :var api_secret: API secret. :vartype api_secret: str :var access_token: OAuth 1.0a access token. :vartype access_token: str :var access_token_secret: OAuth 1.0a access token secret. requests. :vartype access_token_secret: str """ tmpl = '{0}/api/v2' if '.' not in subdomain: subdomain += '.desk.com' self.apiroot = http.quote_any(tmpl.format(port.to_u(subdomain))) self.apiroot = 'https://' + self.apiroot self.oauth = auth.OAuth(access_token, access_token_secret, api_key, api_secret) self.add_filter(self.use_json) # authenticate has to be the last filter, because anything that # modifies the request after it's signed will make the signature # invalid! self.add_filter(self.authenticate)
def __init__(self, parent, object_id=None): self.parent = parent self.object_id = object_id if self.object_id: self.object_id = http.quote_any(self.object_id)
def __init__(self, parent, user, group=None, repo=None): self.parent = parent self.user = user self.group = http.quote_any(group) if group else None self.repo = http.quote_any(repo) if repo else None
def __init__(self, parent, user, repo): self.parent = parent self.user = http.quote_any(user) self.repo = http.quote_any(repo)