Developer

Developer environment tools

const developer = require('developer')

The Developer module exposes various developer-centric environment functionality.

This module is available on development endpoints.

module developer.sessions

const { sessions } = require('developer')

logout(account)

Logs out sessions for an account. If called from a script by the target account during a session and the current session is in the context of the calling request, the caller's session is not closed.

Once closed, the first authenticated access by the target account for any existing sessions results in a cortex.accessDenied.loggedInElsewhere fault.

Arguments

  • account { String | ObjectID } The account email or ID of the target for which sessions are forcibly ended.

module developer.locations

const { locations } = require('developer')

list({ where, pipeline, sort, skip, limit })

Queries environment devices.

Arguments

  • options { Object }

    • where { Object } A query match object.

    • pipeline { Object } An aggregation pipeline object.

    • sort { Object } A query sort object.

    • skip { Number = 0 }

    • limit { Number = Undefined }

Returns

  • list { Object } A list object.

    • hasMore { Boolean } true for more results.

    • data { Object[] } An array of location objects.

    • object { String } "list".

remove( _id )

Removes a device location by _id.

Arguments

  • _id { ObjectID } The ID of the device location to be removed.

Returns

  • location { Object } The location object removed. Returns cortex.notFound.unspecified error if not found.

module developer.environment

View the mdctl-cli GitHub topic for more information about environment import and export.

The following updates are made to Cortex's environment import process in Cortex API 2.17.0:

  • Policies are disabled during import and package install.

  • Backups and triggers are false by default during import.

  • Memo parameter is accessible during ingest and export pipes.

  • Memo parameter is accessible to the beforeImport, afterImport, beforeExport, afterExport scripts.

Include

const { environment } = require('developer')

export(options)

Exports an environment.

Arguments

  • options { Object }

    • manifest { Object } A manifest definition that determines what to export.

    • preferUrls { Boolean = true } When true, exports signed URLs for file data where possible. When false,

      file data is base64-encoded into chunked resource stream objects.

    • silent { Boolean = false } When true, manifest entries without unique keys will be ignored. By default, a cortex.unsupportedOperation.uniqueKeyNotSet fault is occurs.

Returns

  • { Cursor } A cursor to output documents.

import(payload, options)

Imports to an environment.

Arguments

  • payload { Cursor | Object[] } An import stream of documents defining the import (manifest and resources).

  • options { Object }

    • backup { Boolean = true } When true, the deployment mechanism puts the environment into maintenance mode and forces a wholesale rollback if an import error occurs.

    • triggers { Boolean = true } When set to false, script triggers for updated or inserted resources are skipped.

    • production { Boolean = false } In the future, script-based imports may be allowed in production. As a safety measure, the production flag must be set when in production and only when in production.

Returns

  • { Cursor } A cursor to input result documents.

Examples

Export a definition

const { environment } = require('developer')

return environment.export({
  manifest: {            
    objects: [{
      name: 'c_example',
      includes: ['*']
    }]
  }
})

Last updated