Assign resources to an existing project
import { DigitalOcean, RESOURCE_PREFIX } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
const dropletId = 1;
const ip = '192.168.99.100';
// Build resource urns using RESOURCE_PREFIX constant provided.
const resources = [
`${RESOURCE_PREFIX.DROPLET}${dropletId}`, // 'do:droplet:1'
`${RESOURCE_PREFIX.FLOATING_IP}${ip}` // 'do:floatingip:192.168.99.100'
];
const resources = await client.projects
.assignResourcesToProject('project-id', resources);
Create a new project
import { DigitalOcean } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
const request = {
"name": "my-web-api",
"description": "My website API",
"purpose": "Service or API",
"environment": "Production"
};
const project = await client.projects.createProject(request);
Delete an existing project
import { DigitalOcean } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
await client.projects.deleteProject('project-id');
Get all resources attached to the default project
import { DigitalOcean } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
const resources = await client.projects.getDefaultProjectResources();
Get all resources attached to a specific project
import { DigitalOcean } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
const resources = await client.projects.getProjectResources('project-id');
Parses a Project Resource URN into its various parts
import { DigitalOcean } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
const urn = 'do:droplet:4126873';
const resource = await client.projects
.parseProjectResourceUrn(urn);
Update the default project
import { DigitalOcean } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
const request = {
"name": "my-web-api",
"description": "My website API",
"purpose": "Service or API",
"environment": "Staging",
"is_default": true
};
const project = await client.projects.updateDefaultProject(request);
Update an existing project
import { DigitalOcean } from 'digitalocean-deno';
const client = new DigitalOcean('your-api-key');
const request = {
"name": "my-web-api",
"description": "My website API",
"purpose": "Service or API",
"environment": "Staging",
"is_default": false
};
const project = await client.projects.updateProject('project-id', request);
Generated using TypeDoc
Assign resources to the default project
Example
import { DigitalOcean, RESOURCE_PREFIX } from 'digitalocean-deno'; const client = new DigitalOcean('your-api-key'); const dropletId = 1; const ip = '192.168.99.100'; // Build resource urns using RESOURCE_PREFIX constant provided. const resources = [ `${RESOURCE_PREFIX.DROPLET}${dropletId}`, // 'do:droplet:1' `${RESOURCE_PREFIX.FLOATING_IP}${ip}` // 'do:floatingip:192.168.99.100' ]; const resources = await client.projects .assignResourcesToDefaultProject(resources);