Ejemplo n.º 1
0
    def getInventoryItemStatus(self, itemId):
        if itemId is None:
            raise InvalidRequest("Item id must be provided")

        itemId = str(itemId)
        url = '%s/items/domain/inventory/status/%s' % (self.getContextRoot(),
                                                       itemId)

        response = self.sendRequest(url, method="GET")
        return PropertyValue(response)
Ejemplo n.º 2
0
    def addImagePropertyToItemWithId(self, itemId, imageFile):

        url = '%s/items/%s/addImageProperty' % (self.getContextRoot(), itemId)

        fileName, data = self._generateFileData(imageFile)
        fileName = Encoder.encode(fileName)
        url = self._appendUrlParameter(url, 'imageFileName', fileName)

        response = self.sendSessionRequest(url=url, method='POST', data=data)

        return PropertyValue(response)
Ejemplo n.º 3
0
    def updateInventoryItemStatus(self, itemId, status):
        if itemId is None:
            raise InvalidRequest("Item id must be provided")
        if status is None:
            raise InvalidRequest("Status must be provided")

        itemId = str(itemId)

        status = Encoder.encode(status)

        url = "%s/items/domain/inventory/status/%s/%s" % (
            self.getContextRoot(), itemId, status)

        response = self.sendSessionRequest(url, method="POST")

        return PropertyValue(response)
Ejemplo n.º 4
0
    def __createAddPropertyRequest(self,
                                   url,
                                   id,
                                   propertyTypeName,
                                   tag=None,
                                   value=None,
                                   units=None,
                                   description=None,
                                   isUserWriteable=None,
                                   isDynamic=None,
                                   displayValue=None):
        if propertyTypeName is None or not len(propertyTypeName):
            raise InvalidRequest("propertyTypeName must be provided")

        propertyTypeName = Encoder.encode(propertyTypeName)
        url = url % (self.getContextRoot(), id, propertyTypeName)

        if tag is not None:
            tag = Encoder.encode(tag)
            url = self._appendUrlParameter(url, 'tag', tag)

        if value is not None:
            value = Encoder.encode(value)
            url = self._appendUrlParameter(url, 'value', value)

        if displayValue is not None:
            displayValue = Encoder.encode(displayValue)
            url = self._appendUrlParameter(url, 'displayValue', displayValue)

        if units is not None:
            units = Encoder.encode(units)
            url = self._appendUrlParameter(url, 'units', units)

        if description is not None:
            description = Encoder.encode(description)
            url = self._appendUrlParameter(url, 'description', description)

        if isUserWriteable is not None:
            url = self._appendUrlParameter(url, 'isUserWriteable',
                                           isUserWriteable)

        if isDynamic is not None:
            url = self._appendUrlParameter(url, 'isDynamc', isDynamic)

        responseDict = self.sendSessionRequest(url=url, method='POST')

        return PropertyValue(responseDict)