Ejemplo n.º 1
0
    def create(
        cls, api_key=None, idempotency_key=None, octane_version=None, **params
    ):
        requestor = api_requestor.APIRequestor(
            api_key, api_version=octane_version
        )
        url = cls.class_url()
        headers = util.populate_headers(idempotency_key)
        response, api_key = requestor.request("post", url, params, headers)

        return util.convert_to_octane_object(response, api_key, octane_version)
Ejemplo n.º 2
0
 def _static_request(cls,
                     method_,
                     url_,
                     api_key=None,
                     idempotency_key=None,
                     octane_version=None,
                     **params):
     requestor = api_requestor.APIRequestor(api_key,
                                            api_version=octane_version)
     headers = util.populate_headers(idempotency_key)
     response, api_key = requestor.request(method_, url_, params, headers)
     return util.convert_to_octane_object(response, api_key, octane_version)
Ejemplo n.º 3
0
    def save(self, idempotency_key=None):
        updated_params = self.serialize(None)
        headers = util.populate_headers(idempotency_key)

        if updated_params:
            self.refresh_from(
                self.request(
                    "put", self.instance_url(), updated_params, headers
                )
            )
        else:
            util.logger.debug("Trying to save already saved object %r", self)
        return self
Ejemplo n.º 4
0
    def _request(
        self,
        method_,
        url_,
        api_key=None,
        idempotency_key=None,
        octane_version=None,
        **params
    ):
        api_key = api_key or self.api_key
        octane_version = octane_version or self.octane_version

        requestor = api_requestor.APIRequestor(
            api_key, api_version=octane_version
        )
        headers = util.populate_headers(idempotency_key)
        response, api_key = requestor.request(method_, url_, params, headers)
        octane_object = util.convert_to_octane_object(
            response, api_key, octane_version
        )
        return octane_object
Ejemplo n.º 5
0
 def verify(self, idempotency_key=None, **params):
     url = self.instance_url() + "verify"
     headers = util.populate_headers(idempotency_key)
     self.refresh_from(self.request("post", url, params, headers))
     return self
Ejemplo n.º 6
0
 def usage(self, idempotency_key=None, **params):
     url = self.instance_url() + "/usage"
     headers = util.populate_headers(idempotency_key)
     self.refresh_from(self.request("get", url, params, headers))
     return self
Ejemplo n.º 7
0
 def do_stuff(self, idempotency_key=None, **params):
     url = self.instance_url() + "do_the_thing"
     headers = util.populate_headers(idempotency_key)
     self.refresh_from(self.request("post", url, params, headers))
     return self