Environment

View as Markdown

Environment

A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published.

update

The Update Environment call lets you update the name and description of an existing Environment.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).environment('name')

.fetch()

.then((environment) => {

 environment.title = 'My New Content Type'

 environment.description = 'Content Type description'

 return environment.update()

})

.then((environment) => console.log(environment))

delete

The Delete Environment call is used to delete an existing Environment permanently from your Stack.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).environment('name')

.delete()

.then((response) => console.log(response.notice))

fetch

The fetch Environment call fetches Environment details.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).environment('name')

.fetch()

.then((environment) => console.log(environment))

create

The Create a Environment call creates a new environment in a particular stack of your Contentstack account.

NameTypeDescription
params.environmentsobject

The environment details with name, server, urls, and deploy content.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


const environment = {

     name: 'development',

     servers: [

               {

                 name: 'default'

               }

               ],

     urls: [

             {

                 locale: 'en-us',

                 url: 'http://example.com/'

             }

           ],

     deploy_content: true

}


client.stack({ api_key: 'api_key'}).environment().create({ environment })

.then((environment) => console.log(environment))

query

The Query on Environment will allow to fetch details of all or specific Environment.

NameTypeDescription
params.include_countboolean

The `include_count’ parameter includes the count of total number of environment in your stack, along with the details of each environment.

params.limit

The ‘limit’ parameter will return a specific number of environment in the output.

params.skip

The ‘skip’ parameter will skip a specific number of environment in the response.

import * as contentstack from '@contentstack/management'

const client = contentstack.client({ authtoken })


client.stack({ api_key: 'api_key'}).environment()

.query({ query: { name: 'Environment Name' } }).find()

.then((environment) => console.log(environment))