Config

View as Markdown

Config

Config class that exposes config instance, Where the user can provide other configurations on the stack

earlyAccess

With the earlyAccess header support, you can access features that are part of the early access program.

Config config = new Config();

String[] earlyAccess = {"Taxonomy", "Teams", "Terms", "LivePreview"};

config.setEarlyAccess(earlyAccess);

Stack stack = Contentstack.stack(API_KEY, DELIVERY_TOKEN, ENV, config);

getBranch

Get branch of the stack

import com.contentstack.sdk.*;


Config config = new Config();

config.getBranch();

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment, config);

setBranch

Set branch for on the stack

NameTypeDescription
branch (required)String

branch you want to set

import com.contentstack.sdk.*;


Config config = new Config();

config.setBranch("branchName");

Stack stack = Contentstack.stack(apiKey, deliveryToken, environment, config);

setProxy

Sets custom proxy

NameTypeDescription
proxy (required)Proxy

Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object

import com.contentstack.sdk.*;
import java.net.*;

java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort"));
Config config = new Config();
config.setProxy(proxy);

getProxy

Returns the Proxy instance

import com.contentstack.sdk.*;


Config config = new Config();

config.getProxy();

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

connectionPool

Manages reuse of HTTP and HTTP/2 connections for reduced network latency. HTTP requests that * share the same {@link okhttp3.Address} may share a {@link okhttp3.Connection}. This class implements the policy of which connections to keep open for future use.

NameTypeDescription
maxIdleConnections (required)Int

the maxIdleConnections default value is 5

Default: 5
keepAliveDuration (required)long

the keepAliveDuration default value is 5

Default: 5
timeUnit (required)TimeUnit

the timeUnit default value is TimeUnit.MINUTES

Default: TimeUnit.MINUTES
import com.contentstack.sdk.*;


Config config = new Config();

config.connectionPool(maxIdleConnections, keepAliveDuration, timeUnit);

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

getRegion

Get Region of the request url

import com.contentstack.sdk.*;


Config config = new Config();

config.getRegion();

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setRegion()

Sets Region of the database

NameTypeDescription
region (required)ContentstackRegion

DB region for your stack. You can choose from six regions namely, NA, EU, Azure NA, Azure EU, GCP NA, and GCP EU.

Default: ContentstackRegion. US
import com.contentstack.sdk.*;

Config config = new Config();

config.setRegion(ContentstackRegion.EU);

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

getHost()

Gets host of the request

import com.contentstack.sdk.*;


Config config = new Config();

config.getHost();

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setHost()

Set custom host of the request url

NameTypeDescription
hostname (required)String

The host

import com.contentstack.sdk.*;


Config config = new Config();

config.sethost(hostname);

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

getVersion()

Gets version of the request path

import com.contentstack.sdk.*;


Config config = new Config();

config.getVersion();

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

enableLivePreview()

Enables Live Preview

NameTypeDescription
enable (required)Boolean

Provide true to enable the Live Preview

Default: False
import com.contentstack.sdk.*;


Config config = new Config();

config.enableLivePreview(true);

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setLivePreviewHost()

Sets Host to the Live Preview request url

NameTypeDescription
livePreviewHost (required)String

Host for Live Preview

import com.contentstack.sdk.*;


Config config = new Config();

config.setLivePreviewHost(host);

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);

setManagementToken()

Adds Management Token to the stack header

NameTypeDescription
managementToken (required)String

The Management Token

import com.contentstack.sdk.*;


Config config = new Config();

config.setManagementToken(managementToken);

Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);