Exemplo n.º 1
0
def main():
    sourceId = '--Enter your source id--'
    orgId = '--Enter your org id--'
    apiKey = '--Enter your API key--'

    #Setup the push client
    push = CoveoPush.Push(sourceId, orgId, apiKey)

    myfile = 'testfiles\\Example.pptx'
    # Create a document
    mydoc = Document('file:///' + myfile)
    # Get the file contents and add it to the document
    mydoc.GetFileAndCompress(myfile)
    # Set the metadata
    mydoc.AddMetadata("connectortype", "CSV")
    authors = []
    authors.append("Coveo")
    authors.append("R&D")
    # rssauthors should be set as a multi-value field in your Coveo Cloud organization
    mydoc.AddMetadata("rssauthors", authors)
    # Set the title
    mydoc.Title = "THIS IS A TEST"
    # Set permissions
    user_email = "*****@*****.**"
    # Create a permission Identity
    myperm = CoveoPermissions.PermissionIdentity(
        CoveoConstants.Constants.PermissionIdentityType.User, "", user_email)
    # Set the permissions on the document
    allowAnonymous = True
    mydoc.SetAllowedAndDeniedPermissions([myperm], [], allowAnonymous)

    # Push the document
    push.AddSingleDocument(mydoc)
def main():
    sourceId = os.environ.get('PUSH_SOURCE_ID') or '--Enter your source id--'
    orgId = os.environ.get('PUSH_ORG_ID') or '--Enter your org id--'
    apiKey = os.environ.get('PUSH_API_KEY') or '--Enter your API key--'

    # Setup the push client
    push = CoveoPush.Push(sourceId, orgId, apiKey)

    myfile = os.path.join('testfiles', 'Example.pptx')
    # Create a document
    mydoc = Document('file:///' + myfile)
    # Get the file contents and add it to the document
    mydoc.GetFileAndCompress(myfile)
    # Set the metadata
    mydoc.AddMetadata("connectortype", "PPTX")

    # rssauthors should be set as a multi-value field in your Coveo Cloud organization
    mydoc.AddMetadata("rssauthors", ["Coveo", "R&D"])
    # Set the title
    mydoc.Title = "THIS IS A TEST"
    # Set permissions
    user_email = "*****@*****.**"
    # Create a permission Identity
    myperm = CoveoPermissions.PermissionIdentity(
        CoveoConstants.Constants.PermissionIdentityType.User, "", user_email)
    # Set the permissions on the document
    allowAnonymous = True
    mydoc.SetAllowedAndDeniedPermissions([myperm], [], allowAnonymous)

    # Push the document
    push.AddSingleDocument(mydoc)
Exemplo n.º 3
0
def createDoc(myfile, version):
    # Create a document
    mydoc = Document('file:///' + version + "/" + myfile)
    # Get the file and compress it
    mydoc.GetFileAndCompress(myfile)
    # Set Metadata
    mydoc.AddMetadata("connectortype", "CSV")
    authors = []
    authors.append("Coveo")
    authors.append("R&D")
    # rssauthors should be set as a multi-value field in your Coveo Cloud organization
    mydoc.AddMetadata("rssauthors", authors)
    mydoc.Title = "THIS IS A TEST"
    # Set permissions
    user_email = "*****@*****.**"
    myperm = CoveoPermissions.PermissionIdentity(
        CoveoConstants.Constants.PermissionIdentityType.User, "", user_email)
    mydoc.SetAllowedAndDeniedPermissions([myperm], [], True)
    return mydoc