Config
Config
Config class that exposes config instance, Where the user can provide other configurations on the stack
setBranch
The setBranch method sets the target branch for the stack to retrieve content from a specific development or release branch.
| Name | Type | Description |
|---|---|---|
| branch (required) | String | branch you want to set |
import com.contentstack.sdk.*;
Config config = new Config();
config.setBranch("branchName");
Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "environment", config);getBranch
The getBranch method retrieves the branch currently set on the stack.
import com.contentstack.sdk.*; Config config = new Config(); config.getBranch(); Stack stack = Contentstack.stack( "apiKey", "deliveryToken", "environment", config);
setProxy
The setProxy method sets a custom proxy to route SDK network requests through a specified HTTP proxy server.
| Name | Type | Description |
|---|---|---|
| proxy (required) | Proxy | Proxy setting, typically a type (http, socks) and a socket address. A Proxy is an immutable object |
import com.contentstack.sdk.*;
java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", "proxyPort"));
java.net.Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("sl.theproxyvpn.io", 80));
Config config = new Config();
config.setProxy(proxy);getProxy
The getProxy method retrieves the current proxy instance configured for routing network requests.
import com.contentstack.sdk.*; Config config = new Config(); config.getProxy(); Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
getRegion
The getRegion method retrieves the region associated with the request URL.
import com.contentstack.sdk.*; Config config = new Config(); config.getRegion(); Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
setRegion()
The setRegion method sets the database region for your stack. You can choose from seven regions: NA, AU, EU, Azure NA, Azure EU, GCP NA, and GCP EU.
| Name | Type | Description |
|---|---|---|
| region (required) | ContentstackRegion | You can choose from seven regions namely, NA, EU, AU, Azure NA, Azure EU, GCP NA, and GCP EU. |
import com.contentstack.sdk.*;
Config config = new Config();
config.setRegion(ContentstackRegion.EU);
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);getHost()
The getHost method retrieves the host associated with the request URL.
import com.contentstack.sdk.*; Config config = new Config(); config.getHost(); Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
setHost()
The setHost method sets a custom host for the request URL to direct API calls to a specified endpoint.
| Name | Type | Description |
|---|---|---|
| hostname (required) | String | The host |
import com.contentstack.sdk.*; Config config = new Config(); config.sethost(hostname); Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
getVersion()
The getVersion method retrieves the version of the request path.
import com.contentstack.sdk.*; Config config = new Config(); config.getVersion(); Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
enableLivePreview()
Enables Live Preview
| Name | Type | Description |
|---|---|---|
| enable (required) | Boolean | Provide true to enable the Live Preview |
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
| Name | Type | Description |
|---|---|---|
| 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()
The setManagementToken method adds the management token to the stack header to authorize content management operations.
| Name | Type | Description |
|---|---|---|
| managementToken (required) | String | The Management Token |
import com.contentstack.sdk.*; Config config = new Config(); config.setManagementToken(managementToken); Stack stack = Contentstack.stack(<span>context,</span>"apiKey", "deliveryToken", "environment", config);
earlyAccess
The earlyAccess method retrieves features by enabling the early access header, allowing access to functionalities that are part of the early access program.
Example:
Config config = new Config();
String[] earlyAccess = {"Taxonomy", "Teams", "Terms", "LivePreview"};
config.earlyAccess(earlyAccess);
stack = Contentstack.stack("apiKey", "deliveryToken", "environment", config);