The ID of the organization to create the role under
The ID of the entity the role belongs to (for example a user ID)
The role to add ("owner" or "operator")
The type of resource to create the role for ("robot", "location", or "organization")
The ID of the resource the role is being created for
await appClient.addRole(
'<YOUR-ORGANIZATION-ID>',
'<YOUR-USER-ID>',
'owner',
'robot',
'<YOUR-ROBOT-ID>'
);
For more information, see App API.
Changes an existing role.
The existing authorization
The new authorization to change to
const oldAuth = new VIAM.appApi.Authorization({
authorizationType: 'role',
authorizationId: 'organization_owner',
organizationId: '<YOUR-ORGANIZATION-ID>',
resourceId: '<YOUR-RESOURCE-ID>', // The resource to grant access to
resourceType: 'organization', // The type of resource to grant access to
identityId: '<USER-ID>', // The user id of the user to grant access to (optional)
roleId: 'owner', // The role to grant access to
identityType: 'user',
});
const newAuth = new VIAM.appApi.Authorization({
authorizationType: 'role',
authorizationId: 'organization_operator',
organizationId: '<YOUR-ORGANIZATION-ID>',
resourceId: '<YOUR-RESOURCE-ID>', // The resource to grant access to
resourceType: 'organization', // The type of resource to grant access To
identityId: '<USER-ID>', // The user id of the user to grant access to (optional)
roleId: 'operator', // The role to grant access to
identityType: 'user',
});
await appClient.changeRole(oldAuth, newAuth);
For more information, see App API.
Checks whether requested permissions exist.
For more information, see App API.
A list of permissions to check
A filtered list of the authorized permissions
Creates a new fragment.
The ID of the organization to create the fragment under
The name of the new fragment
The new fragment's config
The newly created fragment
const fragment = await appClient.createFragment(
'<YOUR-ORGANIZATION-ID>',
'newFragment'
);
For more information, see App API.
Creates a new API key.
For more information, see App API.
The list of authorizations to provide for the API key
Optional
name: stringAn optional name for the key. If none is passed, defaults to present timestamp
The new key and ID
Creates a new key with an existing key's authorizations
The ID of the key to duplicate
The new key and ID
const key =
await appClient.createKeyFromExistingKeyAuthorizations(
'<YOUR-KEY-ID>'
);
For more information, see App API.
Creates a new location.
The ID of the organization to create the location under
The name of the location to create
Optional
parentLocationId: stringOptional name of a parent location to create the new location under
The location object
const location = await appClient.createLocation(
'<YOUR-ORGANIZATION-ID>',
'name'
);
For more information, see App API.
Create a location secret (LocationAuth
).
The ID of the location to create a LocationAuth
for
The newly created LocationAuth
const locationAuth = await appClient.createLocationSecret(
'<YOUR-LOCATION-ID>'
);
For more information, see App API.
Creates a new module.
The ID of the organization to create the module under
The name of the module
The module ID and a URL to its detail page
const module = await appClient.createModule(
'<YOUR-ORGANIZATION-ID>',
'newModule'
);
For more information, see App API.
Create a new organization.
For more information, see App API.
The name of the new organization
The new organization
Creates a new invitation to join an organization.
The id of the organization to create the invite for
The email address of the user to generate an invite for
The authorizations to associate with the new invite
Bool of whether to send an email invite (true) or automatically add a user. Defaults to true
The organization invite
const auth = new VIAM.appApi.Authorization({
authorizationType: 'role',
authorizationId: 'organization_operator',
organizationId: '<YOUR-ORGANIZATION-ID>',
resourceId: '<YOUR-RESOURCE-ID>', // The resource to grant access to
resourceType: 'organization', // The type of resource to grant access to
identityId: '<YOUR-USER-ID>', // The user id of the user to grant access to (optional)
roleId: 'owner', // The role to grant access to
identityType: 'user',
});
const invite = await appClient.createOrganizationInvite(
'<YOUR-ORGANIZATION-ID>',
'youremail@email.com',
[auth]
);
For more information, see App API.
Create a new registry item.
The ID of the organization to create the registry item under
The name of the registry item
The type of the item in the registry.
await appClient.createRegistryItem(
'<YOUR-ORGANIZATION-ID>',
'newRegistryItemName',
5
);
For more information, see App API.
Deletes a fragment.
The ID of the fragment to delete
await appClient.deleteFragment('12a12ab1-1234-5678-abcd-abcd01234567');
For more information, see App API.
Deletes an existing API key.
The ID of the key to delete
Deletes a location
The ID of the location to delete
Deletes a location secret (LocationAuth
).
The ID of the location to delete the LocationAuth
from
The ID of the location secret to delete
await appClient.deleteLocationSecret(
'<YOUR-LOCATION-ID>',
'<YOUR-SECRET-ID>'
);
For more information, see App API.
Deletes an organization.
The id of the organization to delete
await appClient.deleteOrganization('<YOUR-ORGANIZATION-ID>');
For more information, see App API.
Deletes a pending organization invite.
The ID of the organization
The email associated with the invite to delete
await appClient.deleteOrganizationInvite(
'<YOUR-ORGANIZATION-ID>',
'youremail@email.com'
);
For more information, see App API.
Removes a member from an organization.
The ID of the organization
The ID of the user
await appClient.deleteOrganizationMember(
'<YOUR-ORGANIZATION-ID>',
'<YOUR-USER-ID>'
);
For more information, see App API.
Deletes a registry item.
The ID of the item to delete
await appClient.deleteRegistryItem('<YOUR-REGISTRY-ITEM-ID>');
For more information, see App API.
Deletes a robot.
The ID of the robot to delete
Deletes a robot part.
The ID of the part to delete
Deletes a robot secret from a robot part.
The ID of the part to delete a secret from
The ID of the secret to delete
await appClient.deleteRobotPartSecret(
'<YOUR-ROBOT-PART-ID>',
'<YOUR-SECRET-ID>'
);
For more information, see App API.
Retrieves the app content for an organization.
The public namespace of the organization
The name of the app
The blob path and entrypoint of the app content
const appContent = await appClient.getAppContent(
'<YOUR-PUBLIC-NAMESPACE>',
'<YOUR-APP-NAME>'
);
For more information, see App API.
Get details about an organization.
The ID of the organization
Details about the organization, if it exists
const organization = await appClient.getOrganization(
'<YOUR-ORGANIZATION-ID>'
);
For more information, see App API.
Retrieves user-defined metadata for an organization.
The ID of the organization
The metadata associated with the organization
const metadata = await appClient.getOrganizationMetadata(
'<YOUR-ORGANIZATION-ID>'
);
For more information, see App API.
Find out if an organization namespace is available.
The namespace to query for availability
A boolean indicating whether or not the namespace is available
const isAvailable =
await appClient.getOrganizationNamespaceAvailability('name');
For more information, see App API.
List all organizations with access to a particular location.
The ID of the location to query
The list of locations with access to the requested location
const organizations =
await appClient.getOrganizationsWithAccessToLocation(
'<YOUR-LOCATION-ID>'
);
For more information, see App API.
Get an item from the registry.
The ID of the item to get
The requested item
const registryItem = await appClient.getRegistryItem(
'<YOUR-REGISTRY-ITEM-ID>'
);
For more information, see App API.
Gets a list of a robot's API keys.
The ID of the robot to get API keys for
A list of the robot's API keys
const robotAPIKeys =
await appClient.getRobotAPIKeys('<YOUR-ROBOT-ID>');
For more information, see App API.
Queries a specific robot part by ID.
The ID of the requested robot part
The robot part and a its json config
const robotPart = await appClient.getRobotPart('<YOUR-ROBOT-PART-ID>');
// Get the part's address
const address = robotPart.part.fqdn;
// Check if machine is live (last access time less than 10 sec ago)
if (
Date.now() - Number(robotPart.part.lastAccess.seconds) * 1000 <=
10000
) {
console.log('Machine is live');
}
For more information, see App API.
Get a list containing the history of a robot part.
The ID of the requested robot part
The list of the robot part's history
const robotPartHistory = await appClient.getRobotPartHistory(
'<YOUR-ROBOT-PART-ID>'
);
For more information, see App API.
Get a page of log entries for a specific robot part. Logs are sorted by descending time (newest first).
The ID of the requested robot part
Optional
filter: stringOptional string to filter logs on
Optional
levels: string[]Optional array of log levels to return. Defaults to returning all log levels
Optional string indicating which page of logs to query. Defaults to the most recent
The robot requested logs and the page token for the next page of logs
const robotPartLogs = await appClient.getRobotPartLogs(
'<YOUR-ROBOT-PART-ID>'
);
For more information, see App API.
Retrieves user-defined metadata for a robot part.
The ID of the robot part
The metadata associated with the robot part
const metadata = await appClient.getRobotPartMetadata(
'<YOUR-ROBOT-PART-ID>'
);
For more information, see App API.
Returns a list of rover rental robots for an organization.
The ID of the organization to query
The list of RoverRentalRobot
objects
const roverRentalRobots = await appClient.getRoverRentalRobots(
'<YOUR-ORGANIZATION-ID>'
);
For more information, see App API.
Obtain a user's ID from their email address. Internal use only.
The email address of the user
The user's ID
// This method is used internally only. To obtain a user's ID, use the listOrganizationsByUser method.
const members = await appClient.listOrganizationMembers(
'<YOUR-ORGANIZATION-ID>'
);
For more information, see App API.
List all authorizations for an organization.
For more information, see App API.
The ID of the organization to list authorizations for
Optional
resourceIds: string[]Optional list of IDs of resources to list authorizations for. If not provided, all resources will be included
The list of authorizations
Lists all fragments within an organization.
The ID of the organization to list fragments for
Optional, deprecated boolean. Use fragmentVisibilities instead. If true then only public fragments will be listed. Defaults to true
The list of fragment objects
const fragments = await appClient.listFragments(
'<YOUR-ORGANIZATION-ID>'
);
For more information, see App API.
List all API keys for an organization.
The ID of the organization to query
The list of API keys
const keys = await appClient.listKeys('<YOUR-ORGANIZATION-ID>');
For more information, see App API.
The machine ID used to filter fragments defined in a machine's parts. Also returns any fragments nested within the fragments defined in parts.
Optional
additionalFragmentIds: string[]Additional fragment IDs to append to the response. Useful when needing to view fragments that will be provisionally added to the machine alongside existing fragments.
The list of top level and nested fragments for a machine, as well as additionally specified fragment IDs.
const fragments = await appClient.listMachineFragments(
'<YOUR-MACHINE-ID>'
);
For more information, see App API.
Lists organization memebers and outstanding invites.
The id of the organization to query
An object containing organization members, pending invites, and org ID
const members = await appClient.listOrganizationMembers(
'<YOUR-ORGANIZATION-ID>'
);
For more information, see App API.
List all organizations.
The organization list
const organizations = await appClient.listOrganizations();
For more information, see App API.
List all organizations associated with a user. Internal use only.
The ID of the user to query
The list of locations the requested user has access to
List all registry items for an organization.
The ID of the organization to query registry items for
A list of types to query. If empty, will not filter on type
A list of visibilities to query for. If empty, will not filter on visibility
A list of platforms to query for. If empty, will not filter on platform
A list of statuses to query for. If empty, will not filter on status
Optional
searchTerm: stringOptional search term to filter on
Optional
pageToken: stringOptional page token for results. If not provided, will return all results
The list of registry items
const registryItems = await appClient.listRegistryItems(
'<YOUR-ORGANIZATION-ID>',
[], // All package types
[1], // Private packages
[],
[1] // Active packages
);
For more information, see App API.
Get a location's LocationAuth
(location secret(s)).
The ID of the location to retrieve LocationAuth
from.
The LocationAuth
for the requested location.
const locationAuth = await appClient.locationAuth(
'<YOUR-LOCATION-ID>'
);
For more information, see App API.
Marks a robot part as the main part.
The ID of the part to mark as main
Marks a robot part for restart.
The ID of the part to mark for restart
await appClient.markPartForRestart('<YOUR-ROBOT-PART-ID>');
For more information, see App API.
Creates a new robot.
The ID of the location to create the robot in
The name of the new robot
The new robot's ID
const robotId = await appClient.newRobot(
'<YOUR-LOCATION-ID>',
'newRobot'
);
For more information, see App API.
Creates a new robot part.
The ID of the robot to create a part for
The name for the new robot part
The ID of the newly-created robot part
const robotPartId = await appClient.newRobotPart(
'<YOUR-ROBOT-ID>',
'newPart'
);
For more information, see App API.
Removes a role from an organization.
The ID of the organization to remove the role from
The ID of the entity the role belongs to (for example a user ID)
The role to remove ("owner" or "operator")
The type of resource to remove the role from ("robot", "location", or "organization")
The ID of the resource the role is being removes from
await appClient.removeRole(
'<YOUR-ORGANIZATION-ID>',
'<YOUR-USER-ID>',
'owner',
'robot',
'<YOUR-ROBOT-ID>'
);
For more information, see App API.
Resends a pending organization invite.
The ID of the organization
The email associated with the invite to resend
The invite
const invite = await appClient.resendOrganizationInvite(
'<YOUR-ORGANIZATION-ID>',
'youremail@email.com'
);
For more information, see App API.
Rotates an existing API key.
The ID of the key to rotate
The updated key and ID
Shares a location with another organization
The ID of the organization to share with
The ID of the location to share
await appClient.shareLocation(
'<OTHER-ORGANIZATION-ID>',
'<YOUR-LOCATION-ID>'
);
For more information, see App API.
Get a stream of log entries for a specific robot part. Logs are sorted by descending time (newest first).
The ID of the requested robot part
A queue to put the log entries into
Optional
filter: stringOptional string to filter logs on
Optional bool to indicate whether or not only error-level logs should be returned. Defaults to true
const robotPartLogs = await appClient.tailRobotPartLogs(
'<YOUR-ROBOT-PART-ID>'
);
For more information, see App API.
Unshares a location with an organization
The ID of the organization to unshare with
The ID of the location to unshare
await appClient.unshareLocation(
'<OTHER-ORGANIZATION-ID>',
'<YOUR-LOCATION-ID>'
);
For more information, see App API.
Updates an existing fragment.
The ID of the fragment to update
The name to update the fragment to
The config to update the fragment to
Optional
makePublic: booleanOptional, deprecated boolean specifying whether the fragment should be public or not. If not passed, the visibility will be unchanged. Fragments are private by default when created
Optional
visibility: FragmentVisibilityOptional FragmentVisibility specifying the updated fragment visibility. If not passed, the visibility will be unchanged. If visibility is not set and makePublic is set, makePublic takes effect. If makePublic and visibility are set, they must not be conflicting. If neither is set, the fragment visibility will remain unchanged.
The updated fragment
const fragment = await appClient.updateFragment(
'12a12ab1-1234-5678-abcd-abcd01234567',
'better_name'
);
For more information, see App API.
Updates location details.
The ID of the location to update
Optional
name: stringOptional string to update the location's name to
Optional
parentLocId: stringOptional string to update the location's parent location to
Optional
region: stringOptional string to update the location's region to
The location object
const location = await appClient.updateLocation(
'<YOUR-LOCATION-ID>',
'newName'
);
For more information, see App API.
Updates an existing module.
The ID of the module to update
The visibility to set for the module
The url to reference for documentation, code, etc.
A short description of the module
A list of models available in the module
The executable to run to start the module program
The module URL
const module = await appClient.updateModule(
'<YOUR-MODULE-ID>',
1,
'https://example.com',
'new description',
[{ model: 'namespace:group:model1', api: 'rdk:component:generic' }],
'entrypoint'
);
For more information, see App API.
Updates organization details.
The id of the organization to update
Optional
name: stringOptional name to update the organization with
Optional
publicNamespace: stringOptional namespace to update the organization with
Optional
region: stringOptional region to update the organization with
Optional
cid: stringOptional CRM ID to update the organization with
The updated organization details
const organization = await appClient.updateOrganization(
'<YOUR-ORGANIZATION-ID>',
'newName'
);
For more information, see App API.
Updates authorizations for an existing org invite.
The id of the organization
The email address associated with the invite
List of authorizations to add to the invite
List of authorizations to remove from the invite
The organization invite
const auth = new VIAM.appApi.Authorization({
authorizationType: 'role',
authorizationId: 'organization_operator',
organizationId: '<YOUR-ORGANIZATION-ID>',
resourceId: '<YOUR-RESOURCE-ID>', // The resource to grant access to
resourceType: 'organization', // The type of resource to grant access to
identityId: '<YOUR-USER-ID>', // The user id of the user to grant access to (optional)
roleId: 'owner', // The role to grant access to
identityType: 'user',
});
const invite = await appClient.updateOrganizationInviteAuthorizations(
'<YOUR-ORGANIZATION-ID>',
'youremail@email.com',
[auth],
[]
);
For more information, see App API.
Updates user-defined metadata for an organization.
The ID of the organization
The metadata to update
await appClient.updateOrganizationMetadata('<YOUR-ORGANIZATION-ID>', {
key: 'value',
});
For more information, see App API.
Update an existing registry item.
The ID of the registry item to update
The PackageType to update the item to
A description of the item
A visibility value to update to
await appClient.updateRegistryItem(
'<YOUR-REGISTRY-ITEM-ID>',
5, // Package: ML Model
'new description',
1 // Private
);
For more information, see App API.
Change the name of an existing machine. You can only change the name of the machine, not the location.
The ID of the robot to update
The ID of the location where the robot is
The name to update the robot to
The newly-modified robot object
const robot = await appClient.updateRobot(
'<YOUR-ROBOT-ID>',
'<YOUR-LOCATION-ID>',
'newName'
);
For more information, see App API.
Updates a robot part based on its ID.
The ID of the requested robot part
The new name of the robot part
The new config for the robot part
The updated robot part
const robotPart = await appClient.updateRobotPart(
'<YOUR-ROBOT-PART-ID>',
'newName'
);
For more information, see App API.
Add a role under an organization.