BranchAliasModel

View as Markdown

BranchAliasModel

BranchAliasModel holds the UID of an alias that points to a branch.

When to Use This Class: Use this class to read which aliases point to a branch, from the Alias list of a fetched BranchModel.

Conceptual Role: Acts as the item type of BranchModel.Alias. The SDK has no class that creates, updates, or deletes an alias.

Returns: BranchAliasModel. The UID of one alias.

Class-Level Notes

The API sets the alias list.

  • The API sets the aliases of a branch. Assign or remove an alias through the Content Management API.
  • When you delete a branch, the API also deletes every alias that points to it.

Method Index

BranchAliasModel has no methods. Read its Uid property from the items of BranchModel.Alias.

Class-Level Snippet

This snippet fetches a branch and prints the UID of each alias that points to it.

using System;
using System.Text.Json;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;

ContentstackClient client = new ContentstackClient("<AUTHTOKEN>", "<API_HOST>");

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").Branch("<BRANCH_UID>").Fetch();
    BranchModel? branch = response.OpenJsonObjectResponse()["branch"]?.Deserialize<BranchModel>();

    foreach (BranchAliasModel alias in branch?.Alias ?? new())
    {
        Console.WriteLine(alias.Uid);
    }
}
catch (ContentstackErrorException ex)
{
    Console.WriteLine($"API error {(int)ex.StatusCode}: {ex.ErrorMessage}");
}
NameTypeDescription
Uid string

Alias UID, for example production. Serialized as uid.