示例#1
0
    def getItemByUniqueAttributes(self,
                                  domainName,
                                  itemName,
                                  itemIdentifier1=None,
                                  itemIdentifier2=None,
                                  derivedFromItemId=None):
        if domainName is None or not len(domainName):
            raise InvalidRequest("domainName must be provided")

        if itemName is None or not len(itemName):
            raise InvalidRequest("itemName must be provided")

        domainName = Encoder.encode(domainName)
        itemName = Encoder.encode(itemName)
        url = '%s/items/uniqueAttributes/%s/%s' % (self.getContextRoot(),
                                                   domainName, itemName)

        if itemIdentifier1 is not None:
            itemIdentifier1 = Encoder.encode(str(itemIdentifier1))
            url = self._appendUrlParameter(url, "itemIdentifier1",
                                           itemIdentifier1)

        if itemIdentifier2 is not None:
            itemIdentifier2 = Encoder.encode(str(itemIdentifier2))
            url = self._appendUrlParameter(url, "itemIdentifier2",
                                           itemIdentifier2)

        if derivedFromItemId is not None:
            url = self._appendUrlParameter(url, "derivedFromItemId",
                                           derivedFromItemId)

        responseData = self.sendRequest(url=url, method="GET")
        return Item(responseData)
示例#2
0
    def getItemByQrId(self, itemQrId):
        if itemQrId is not None:
            itemQrId = str(itemQrId)
        if itemQrId is None or not len(itemQrId):
            raise InvalidRequest("itemQrId must be provided")

        url = '%s/items/%s/qrId' % (self.getContextRoot(), itemQrId)

        responseData = self.sendRequest(url=url, method='GET')
        return Item(responseData)
示例#3
0
    def addItem(self,
                domainName,
                name,
                itemProjectName=None,
                itemIdentifier1=None,
                itemIdentifier2=None,
                qrId=None,
                description=None,
                ownerUserId=None,
                ownerGroupId=None,
                isGroupWriteable=None,
                entityTypeNames=None,
                derivedFromItemId=None):
        if domainName is None or not len(domainName):
            raise InvalidRequest("domainName must be provided")

        if name is None or not len(name):
            raise InvalidRequest("name must be provided")

        name = Encoder.encode(name)
        domainName = Encoder.encode(domainName)

        url = '%s/items/add/%s/domain/%s' % (self.getContextRoot(), name,
                                             domainName)

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

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

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

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

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

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

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

        if entityTypeNames is not None:
            entityTypeNames = Encoder.encode(str(entityTypeNames))
            url = self._appendUrlParameter(url, "entityTypeNames",
                                           entityTypeNames)

        if derivedFromItemId is not None:
            url = self._appendUrlParameter(url, "derivedFromItemId",
                                           derivedFromItemId)

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

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

        return Item(responseData)