Server
Server
Server names one deployment server of a publishing environment.
When to Use This Class: Use this class to list the deployment servers of an environment in EnvironmentModel.Servers.
Conceptual Role: Acts as the item type of EnvironmentModel.Servers. No method takes it directly.
Returns: Server. One deployment server of an environment.
Class-Level Notes
Where it goes.
- Add Server objects to the Servers list of an EnvironmentModel, then pass the model to the Create or Update method of Environment.
- A Name you leave null stays out of the request body, so the server goes out as an empty object.
Properties
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| Name | string? | No | null | Name of the server. Serialized as name. |
Method Index
Server has no methods. Set its properties and pass it to the methods named above.
Class-Level Snippet
The snippet below adds a staging environment with two deployment servers.
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
EnvironmentModel model = new EnvironmentModel()
{
Name = "staging",
Servers = new List<Server>()
{
new Server() { Name = "staging-web-1" },
new Server() { Name = "staging-web-2" }
},
Urls = new List<LocalesUrl>() { new LocalesUrl() { Locale = "en-us", Url = "https://staging.example.com" } }
};
try
{
ContentstackResponse response = client.Stack("<API_KEY>").Environment().Create(model);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}