예제 #1
0
    def addons(self, val):
        """Set addons
        Keyword argument:
        val -- New addons value"""
        if val is None:
            self._addons = []
            return self

        if len(val) > 0 and isinstance(val[0], processout.Addon):
            self._addons = val
        else:
            l = []
            for v in val:
                obj = processout.Addon(self._client)
                obj.fill_with_data(v)
                l.append(obj)
            self._addons = l
        return self
예제 #2
0
    def find_addon(self, addon_id, options={}):
        """Find a subscription's addon by its ID.
        Keyword argument:
        addon_id -- ID of the addon
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path = "/subscriptions/" + quote_plus(
            self.id) + "/addons/" + quote_plus(addon_id) + ""
        data = {}

        response = Response(request.get(path, data, options))
        return_values = []

        body = response.body
        body = body["addon"]
        addon = processout.Addon(self._client)
        return_values.append(addon.fill_with_data(body))

        return return_values[0]
예제 #3
0
    def fetch_addons(self, options={}):
        """Get the addons applied to the subscription.
        Keyword argument:
        
        options -- Options for the request"""
        self.fill_with_data(options)

        request = Request(self._client)
        path = "/subscriptions/" + quote_plus(self.id) + "/addons"
        data = {}

        response = Response(request.get(path, data, options))
        return_values = []

        a = []
        body = response.body
        for v in body['addons']:
            tmp = processout.Addon(self._client)
            tmp.fill_with_data(v)
            a.append(tmp)

        return_values.append(a)

        return return_values[0]
예제 #4
0
 def new_addon(self, prefill=None):
     """Create a new Addon instance
     Keyword argument:
     prefill -- Data used to prefill the object (optional)"""
     return processout.Addon(self, prefill)