Design: Accessing and Updating Your Library

Modified on Thu, 30 May at 2:08 PM

TABLE OF CONTENTS


Accessing your library

DesLibrary provides information about a library, given a workspaceUrl, in the format 

"https://altium-inc-1234.365.altium.com/"

Using our visual data model, Voyager, you can see desLibrary and what can be returned:

Here is an example query using desLibrary:

query library {
  desLibrary(workspaceUrl: "https://altium-inc-1234.365.altium.com/") {
    name
    eventChannel
    description
    version
    createdBy {
      userName
      userId
      email
    }
    createdAt
    updatedAt
    updatedBy {
      userName
      userId
      email
    }
    folders {
      path
      id
    }
    components {
      nodes {
        name
        id
      }
    }
    reuseBlocks {
      nodes {
        id
        name
        description
      }
    }
  }
}

With this response:

{
  "data": {
    "desLibrary": {
      "createdBy": {
        ...
      },
      "createdAt": "2012-11-01T08:48:39.000Z",
      "updatedAt": "2018-11-13T01:09:50.000Z",
      "updatedBy": {
        ...
      },
      "folders": [
     ...
      ],
      "components": {
        "nodes": [
          {
            "name": "CMP-00000-12",
            "id": "RGVz..."
          }
...
        ]
      },
      "name": "est Workspace"
    }
  },
  "extensions": {
    "requestId": "3c238b16-cca4-42df-8085-7393eca300fc"
  }
}



Modifying your library folders

The Nexar API has mutations that allow for creating, moving, updating and deleting folders.


Create a new folder


To create a new folder, we use desCreateFolder

This is found in our data model, the Voyager, under Mutations.

Required fields

workspaceUrl of the workspace you want the folder to be created

Name of the folder

Folder type


Optional fields

Folder description

Parent folder ID. If this is null, the folder will be placed under the library root.

Naming scheme for folder

Folder permissions


mutation createFolder {
  desCreateFolder(
    input: {
      workspaceUrl: "https://altium-inc-1234.365.altium.com/"
      name: "test_create_folder"
      description: "A test folder"
      folderType: GENERIC_FOLDER
      parentId: "RGVzQ35..."
      itemNamingSchemeTemplate: "Naming Scheme 1"
      permissions: { canModify: true, scope: ANYONE }
    }
  ) {
    errors {
      message
    }
    id
  }
}

Updating folders

Required fields: 

Folder id for the folder you want to change the permissions of

Permissions that you want to change


Optional fields:

Whether all existing permissions should be replaced or not

Whether these permissions apply to folder children

mutation updateFolder {
  desUpdateFolder (input: 
  {
    id: "RGVz..."
    name: "test_update_name"
    description: "updated description"
    folderType: null
    itemNamingSchemeTemplate: "Different template"
    permissions: {canModify: true, scope: ANYONE }

  }) {
    errors {message}
  }
}


Update folder permissions

Note: If replaceExisting is set to true, this mutation will overwrite all existing permissions for this folder.


Required fields: 

Folder id for the folder you want to change the permissions of

Permissions that you want to change


Optional fields:

Whether all existing permissions should be replaced or not

Whether these permissions apply to folder children



mutation updateFolderPermissions {
  desUpdateFolderPermissions(
    input: {
      folderId: "RGVzR..."
      replaceExisting: false
      applyToChildren: true
      permissions: { canModify: true, scope: OWNER }
    }
  ) {
    folderId
  }
}


Move folder

Required fields: 

Folder ID

Parent ID for the new parent folder



mutation moveFolder {
  desMoveFolder(
    input: {
      id: "RGVz..."
      parentId: "RGVo..."
    }
  ) {
    errors {
      message
    }
  }
}


Delete folder

Required fields: 

Folder ID



mutation moveFolder {
  desDeleteFolder(
    input: {
      id: "RGVz..."
    }
  ) {
    errors {
      message
    }
  }
}

Update reuse block

Reuse blocks are common 'sections' of circuitry that can be added to any PCB design without having to start from scratch each time. You can find more about reuse blocks here: https://www.altium.com/documentation/altium-designer/reuse-blocks-snippets


Required fields: 

Reuse block ID


Optional fields:

New name for the reuse block

New description for the reuse block

 

mutation updateReuseBlock {
  desUpdateReuseBlock(
    input: {
      id: "RGVz..."
      name: "Reuse block 2"
      description: "Description of reuse block 2"
    }
  ) {
    errors {
      message
    }
  }
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article