def update(self, alert_policy): """ Update certain parameters of an Alert Policy. :var alert_policy: Representation of the Alert Policy object. :vartype alert_policy: str """ params = base.get_params(None, locals()) url = '{0}.json'.format(self.get_url()) request = http.Request('PUT', url, params) return request, parsers.parse_json
def filter(self, filter_id): """ Fetch a collection filtered. :var filter: a valid resource's filter. :vartype filter: str """ self.require_collection() url = '{0}/{1}'.format(self.get_url(), filter_id) request = http.Request('GET', url) return request, parsers.parse_json
def get(self, limit): """ Returns a specified number of "high-value" bitly links that are popular across bitly at this particular moment. :var limit: the maximum number of high-value links to return. :vartype limit: int """ params = base.get_params(None, locals()) request = http.Request('GET', self.get_url(), params) return request, parsers.parse_json
def get(self, start=None, limit=None): """ .. py:function:: get `get()` method for all the EffiPeople resources. :param int start: Start of the results :param int limit: Limit of the results """ params = base.get_params(('start', 'limit'), locals()) request = http.Request('GET', self.get_url(), params) return request, parsers.parse_json
def performance(self, from_=None, to=None, resolution=None, includeuptime=None, probes=None, order=None): params = base.get_params(None, locals(), translate_param=resource.translate_param) url = self.get_url('performance') return http.Request('GET', url, params), parsers.parse_json
def test_oauth(self): req = http.Request('GET', 'http://example.net/', {'arg': 'val'}) self.auth(req) self.check_signature(req, 'BCd8cSS%2FCujJjfYSwG9MzfJRA7o%3D') req = http.Request('POST', 'http://example.net/', {'arg': 'val'}) self.auth(req) self.check_signature(req, '11x9m5rxVBRKjksv9Qei2QCFLMw%3D') req = http.Request('POST', 'http://example.net/', {'!foo': '~bar'}) self.auth(req) self.check_signature(req, '6yW45xEiPMbEvVdt9bCbgFznrIc%3D') no_body_sig = 'WiLmVChCp3f75uueQM5viSLPHIo%3D' req = http.Request('POST', 'http://example.net/', 'foo') self.auth(req) self.check_signature(req, no_body_sig) req = http.Request('POST', 'http://example.net/', 'bar') self.auth(req) self.check_signature(req, no_body_sig)
def average(self, from_=None, to=None, probes=None, includeuptime=None, bycountry=None, byprobe=None): params = base.get_params(None, locals(), translate_param=resource.translate_param) url = self.get_url('average') return http.Request('GET', url, params), parsers.parse_json
def is_collaborator(self, user): """ Check if a user is a collaborator in this repo. :var user: The username to check. :vartype user: str :return: bool """ url = '{0}/{1}'.format(self.get_url(), user) return http.Request('GET', url), resource.parse_boolean
def add(self, user): """ Add a collaborator to this repo. :var user: The username of the new collaborator. :vartype user: str """ url = '{0}/{1}'.format(self.get_url(), user) # include a body, because requests does not send content-length when no # body is present, and that makes GitHub respond with HTTP 411 return http.Request('PUT', url, '*'), parsers.parse_empty
def get(self, email, password): """ Returns all authorizations for a particular user. Authorization objects contain the API tokens the user has with different company accounts in Pipedrive. Upstream documentation: https://developers.pipedrive.com/v1#methods-Authorizations """ params = base.get_params(None, locals()) return http.Request('POST', self.get_url(), params), parsers.parse_json
def get(self, state=None, cursor=None, per_page=None): """ Fetch all your invoices. :var state: The state of invoices to return: "open", "collected", "failed", or "past_due". :vartype state: str """ params = base.get_params(('state', 'cursor', 'per_page'), locals()) request = http.Request('GET', self.get_url(), params) return request, parsers.parse_xml
def create(self, flag): """ Create a new flag. :var flag: The flag name. Refer to the upstream documentation for details. :vartype flag: str """ self.require_collection() request = http.Request('POST', self.get_url(), self.wrap_object(flag)) return request, parsers.parse_json
def grant(self, obj): """ Create a new resource. :var obj: a Python object representing the resource to be created, usually in the same format as returned from `get`. Refer to the upstream documentation for details. """ self.require_collection() request = http.Request('POST', self.get_url(), self.wrap_object(obj)) return request, parsers.parse_empty
def readme(self, ref=None): """ This method returns the preferred README for a repository. :var ref: Optional string name of the commit/branch/tag. Defaults to master. :vartype ref: str """ params = base.get_params(None, locals()) url = '{0}/readme'.format(self.parent.get_url()) return http.Request('GET', url, params), parsers.parse_json
def update(self, obj): """ Update this resource. :var obj: a Python object representing the updated resource, usually in the same format as returned from `get`. Refer to the upstream documentation for details. """ self.require_item() request = http.Request('POST', self.get_url(), self.wrap_object(obj)) return request, parsers.parse_json
def update(self, server): """ Update certain parameters of a Server. :var server: Representation of the Server object. :vartype server: str """ params = base.get_params(None, locals()) url = '{0}.json'.format(self.get_url()) request = http.Request('PUT', url, params) return request, parsers.parse_json
def get(self, page=None): """ Fetch all resources. :var page: the page that will be return. If not indicated, first one is returned. :vartype page: int """ params = base.get_params(None, locals()) request = http.Request('GET', self.get_url(), params) return request, parsers.parse_json
def find(self, term, currency=None, start=None, limit=None): """ Returns data about the products that were found. If currency was set in request, prices in that currency are served back. Upstream documentation: https://developers.pipedrive.com/v1#methods-Products """ params = base.get_params(None, locals()) url = '{0}/find'.format(self.get_url()) return http.Request('GET', url, params), parsers.parse_json
def get(self, type='all', page=None, per_page=None): """ Fetch repos for this user. :var type: What type of repos to fetch. For details of allowed values, see http://developer.github.com/v3/repos/#list-user-repositories. """ params = base.get_params(('page', 'per_page'), locals()) params['type'] = type request = http.Request('GET', self.get_url(), params) return request, parsers.parse_json
def insert(self, events): """ Submit event or events to rubicon :var events: Event data :vartype event: dict Upstream documentation: http://docs.newrelic.com/docs/rubicon/inserting-events """ url = '{0}/{1}'.format(self.get_url(insert=True), 'events') return http.Request('POST', url, events), parsers.parse_json
def get(self, term=None): """ Returns all supported currencies which should be used when saving monetary values with other objects. The 'code' parameter of the returning objects is the currency code according to ISO 4217. Upstream documentation: https://developers.pipedrive.com/v1#methods-Currencies """ params = base.get_params(None, locals()) return http.Request('GET', self.get_url(), params), parsers.parse_json
def push(self, obj): """ Send a value or a list of values. Each value can have a timestamp associated with it. Timestamps should be UNIX timestamps expressed as numbers. If no timestamp is specified, the value is assumed to be timestamped with the current time. :var obj: a Python object representing the value to push to the data source. See http://dev.ducksboard.com/apidoc/push-api/#post-values-label """ request = http.Request('POST', self.get_push_url(), obj) return request, parsers.parse_json
def upcoming(self, customer): """ Fetch a customer's upcoming invoice. :var customer: The identifier of the customer whose invoices to return. If none is provided, all invoices will be returned. :vartype customer: str """ params = base.get_params(None, locals()) url = '{0}/{1}'.format(self.get_url(), 'upcoming') request = http.Request('GET', url, params) return request, parsers.parse_json
def get_pdf(self, language='en-US'): """ Fetch a PDF blob for the invoice. :var language: The language for the invoice, defaults to "en-US'. :vartype language: str """ self.require_item() headers = {'Accept': 'application/pdf', 'Accept-Language': language} request = http.Request('GET', self.get_url(), {}, headers) return request, parse_passthrough
def numeric(self, event, from_date, to_date, on, buckets, unit=None, where=None, type=None): """ Fetch segmented and filtered data for an event, sorted into numeric buckets. """ params = base.get_params(('event', 'from_date', 'to_date', 'on', 'buckets', 'unit', 'where', 'type'), locals(), serialize_param) request = http.Request('GET', 'segmentation/numeric/', params) return request, parsers.parse_json
def query(self, nrql): """ NRQL query :var nqrl: The nrql query :vartype nqrl: str Upstream documentation: http://docs.newrelic.com/docs/rubicon/using-nrql """ params = base.get_params(None, locals()) url = '{0}/{1}'.format(self.get_url(), 'query') return http.Request('GET', url, params), parsers.parse_json
def create(self, file, user_id=None, deal_id=None, person_id=None, org_id=None): params = base.get_params(None, locals()) params.pop('file', None) return http.Request('POST', self.get_url(), params, files={"file": file}), parsers.parse_json
def create(self, organization=None): """ Fork this repo. :var organization: Specify the organization you would like to fork to. If left as `None` repo will fork to current user. :vartype organization: str """ params = base.get_params(('organization', ), locals()) request = http.Request('POST', self.get_url(), params) return request, parsers.parse_json
def tickets(self, start_time): """ Retrieve tickets that changed in Zendesk "since last you asked" :var start_time: The time of the oldest ticket you are interested in. Tickets modified on or since this time will be returned. The start time is provided as the number of seconds since epoch UTC. :vartype start_time: int """ url = '{0}/{1}'.format(self.get_url(), 'tickets') params = base.get_params(('start_time',), locals()) return http.Request('GET', url, params), parsers.parse_json
def get(self, state='live', cursor=None, per_page=None): """ Fetch all your subscription. :var state: The state of subscriptions to return: "active", "canceled", "expired", "future", "in_trial", "live", or "past_due". A subscription will belong to more than one state. :vartype state: str """ params = base.get_params(None, locals()) request = http.Request('GET', self.get_url(), params) return request, parsers.parse_xml