BulkDeleteAsset

View as Markdown

BulkDeleteAsset

BulkDeleteAsset identifies one asset in a bulk delete request. Add it to BulkDeleteDetails.Assets before you call the Delete method.

When to Use This Class: Use this class once for each asset that a bulk delete request removes.

Conceptual Role: Acts as one object of the assets array in the request body.

Returns: BulkDeleteAsset. One asset of a bulk delete.

Properties

NameTypeRequiredDefaultDescription
Uidstring?NonullUID of the asset. Serialized as uid.

Class-Level Notes

Serialization.

  • The SDK serializes the model with System.Text.Json and leaves out every property that is null. The SDK does not check the values.

Method Index

BulkDeleteAsset has no methods. Set its properties and pass it as shown in the Class-Level Snippet below.

Class-Level Snippet

The snippet below deletes one asset together with an entry.

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>");

BulkDeleteDetails details = new BulkDeleteDetails()
{
    Entries = new List<BulkDeleteEntry>
    {
        new BulkDeleteEntry() { Uid = "<ENTRY_UID>", ContentType = "<CONTENT_TYPE_UID>", Locale = "<LOCALE_CODE>" }
    },
    Assets = new List<BulkDeleteAsset>
    {
        new BulkDeleteAsset() { Uid = "<ASSET_UID>" }
    }
};

try
{
    ContentstackResponse response = client.Stack("<API_KEY>").BulkOperation().Delete(details);
    Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
    // Thrown when the API rejects the request
    Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}