How to use the forge-apis.ProjectsApi function in forge-apis

To help you get started, we’ve selected a few forge-apis examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Autodesk-Forge / forge-upgradefiles-revit / routes / common / da4revitImp.js View on Github external
async function getNewCreatedStorageInfo(projectId, folderId, fileName, oauth_client, oauth_token) {

    // create body for Post Storage request
    let createStorageBody = createBodyOfPostStorage(folderId, fileName);

    const project = new ProjectsApi();
    let storage = await project.postStorage(projectId, createStorageBody, oauth_client, oauth_token);
    if (storage === null || storage.statusCode !== 201) {
        console.log('failed to create a storage.');
        return null;
    }

    // setup the url of the new storage
    const strList = storage.body.data.id.split('/');
    if (strList.length !== 2) {
        console.log('storage id is not correct');
        return null;
    }
    const storageUrl = "https://developer.api.autodesk.com/oss/v2/buckets/" + AUTODESK_HUB_BUCKET_KEY + "/objects/" + strList[1];
    return {
        "StorageId": storage.body.data.id,
        "StorageUrl": storageUrl
github Autodesk-Forge / bim360appstore-viewer-nodejs-visual.reports / server / data.management.tree.js View on Github external
function getFolders(hubId, projectId, tokenSession, res) {
        // if the caller is a project, then show folders

        var projects = new forgeSDK.ProjectsApi();
        projects.getProjectTopFolders(hubId, projectId, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
          .then(function (topFolders) {
            var folderItemsForTree = [];
            topFolders.body.data.forEach(function (item) {
              folderItemsForTree.push(prepareItemForTree(
                item.links.self.href,
                item.attributes.displayName == null ? item.attributes.name : item.attributes.displayName,
                item.type,
                true
              ))
            });
            res.json(folderItemsForTree);
          })
          .catch(function (error) {
            console.log(error);
            res.status(500).end();
github Autodesk-Forge / bim360appstore-model.derivative-nodejs-xls.exporter / server / data.management.tree.js View on Github external
function getFolders(hubId, projectId, tokenSession, res) {
        // if the caller is a project, then show folders

        var projects = new forgeSDK.ProjectsApi();
        projects.getProjectTopFolders(hubId, projectId, tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
          .then(function (topFolders) {
            var folderItemsForTree = [];
            topFolders.body.data.forEach(function (item) {
              folderItemsForTree.push(prepareItemForTree(
                item.links.self.href,
                item.attributes.displayName == null ? item.attributes.name : item.attributes.displayName,
                item.type,
                true
              ))
            });
            res.json(folderItemsForTree);
          })
          .catch(function (error) {
            console.log(error);
            res.status(500).end();
github Autodesk-Forge / bim360appstore-model.derivative-nodejs-xls.exporter / server / data.management.tree.js View on Github external
function getProjects(hubId, tokenSession, res) {
        // if the caller is a hub, then show projects
        var projects = new forgeSDK.ProjectsApi();

        //console.log(tokenSession.getInternalOAuth());
        //console.log(tokenSession.getInternalCredentials());

        projects.getHubProjects(hubId, {},
          tokenSession.getInternalOAuth(), tokenSession.getInternalCredentials())
        .then(function (projects) {
          var projectsForTree = [];
          projects.body.data.forEach(function (project) {
            var projectType = 'projects';
            switch (project.attributes.extension.type) {
              case 'projects:autodesk.core:Project':
                projectType = 'a360projects';
                break;
              case 'projects:autodesk.bim360:Project':
                projectType = 'bim360projects';
github Autodesk-Forge / bim360appstore-data.management-nodejs-transfer.storage / server / forge / tree.js View on Github external
function getFolders(hubId, projectId, oauthClient, credentials, res) {
  var projects = new forgeSDK.ProjectsApi();
  projects.getProjectTopFolders(hubId, projectId, oauthClient, credentials)
    .then(function (topFolders) {
      var folderItemsForTree = [];
      topFolders.body.data.forEach(function (item) {
        folderItemsForTree.push(prepareItemForTree(
          item.links.self.href,
          item.attributes.displayName == null ? item.attributes.name : item.attributes.displayName,
          item.type,
          true
        ))
      });
      res.json(folderItemsForTree);
    })
    .catch(function (error) {
      console.log(error);
      res.status(500).end();
github Autodesk-Forge / forge.commandline-nodejs / api / dm.js View on Github external
.then((oa3Legged) => {
				let projects = new ForgeAPI.ProjectsApi();
				return (projects.getHubProjects(hubId, {}, oa3Legged, oa3Legged.credentials));
			})
			.then((projects) => {
github Autodesk-Forge / forge-boilers.nodejs / 6 - viewer+server+data-mng+derivatives / src / server / api / services / DMSvc.js View on Github external
constructor(config) {

    super(config)

    this._projectsAPI = new Forge.ProjectsApi()
    this._versionsAPI = new Forge.VersionsApi()
    this._foldersAPI = new Forge.FoldersApi()
    this._itemsAPI = new Forge.ItemsApi()
    this._hubsAPI = new Forge.HubsApi()
  }
github Autodesk-Forge / forge.commandline-nodejs / api / dm.js View on Github external
.then((oa3Legged) => {
				let projects = new ForgeAPI.ProjectsApi();
				return (projects.getProjectTopFolders(hubId, projectId, oa3Legged, oa3Legged.credentials));
			})
			.then((folders) => {
github Autodesk-Forge / learn.forge.viewhubmodels / routes / datamanagement.js View on Github external
async function getProjects(hubId, oauthClient, credentials, res) {
    const projects = new ProjectsApi();
    const data = await projects.getHubProjects(hubId, {}, oauthClient, credentials);
    res.json(data.body.data.map((project) => {
        let projectType = 'projects';
        switch (project.attributes.extension.type) {
            case 'projects:autodesk.core:Project':
                projectType = 'a360projects';
                break;
            case 'projects:autodesk.bim360:Project':
                projectType = 'bim360projects';
                break;
        }
        return createTreeNode(
            project.links.self.href,
            project.attributes.name,
            projectType,
            true