1. コマンド

コマンド クライアント

Version:
日本語翻訳に関する免責事項

このページの翻訳はAIによって自動的に行われました。可能な限り正確な翻訳を心掛けていますが、原文と異なる表現や解釈が含まれる場合があります。正確で公式な情報については、必ず英語の原文をご参照ください。

SDK では、Sitecore Content Hub に公開登録されているコマンドを実行するコマンド クライアントを提供しています。

コマンドの実行

コマンドを実行するには、次の情報が必要です。

  • コマンドの名前空間
  • コマンド名
  • コマンドの引数 (コマンドによって異なります)

SDK を使用してコマンドを実行するには:

await MClient.Commands.ExecuteCommandAsync(namespace, name, args);

サポートされているコマンド

使用可能なコマンドのリストは次のとおりです。

名前空間コマンド名引数
external.actionexternal.action
new JObject(
    new JProperty("entity_id", <entity id>),
    new JProperty("action_id", <action id>),
    new JProperty("properties", new JArray()),
    new JProperty("relations", new JArray()),
    new JProperty("action_execution_source", "ExternalAction"),
    new JProperty("extra_data", new JObject())
            
automationapply.state
new JObject(
    new JProperty("target_id", <target id>),
    new JProperty("route_id", <route id>))
            
derivativescreate.variant
new JObject(
    new JProperty("source_entity_id", <surce entity id>),
    // you can provide the copy_profile_identifier or copy_profile_id
    new JProperty("copy_profile_id", <copy profile id>),
    new JProperty("culture", <CultureInfo>),
    new JProperty("properties_overrides", new JObject()),
    new JProperty("relations_overrides", new JObject()))
            

external.action コマンド

using Newtonsoft.Json.Linq;

JObject args = new JObject(
new JProperty("entity_id", 30897),
new JProperty("action_id", 12345),
new JProperty("properties", new JArray()),
new JProperty("relations", new JArray()),
new JProperty("action_execution_source", "ExternalAction"),
new JProperty("extra_data", new JObject(new JProperty("culture", "en-US"))));

await MClient.Commands.ExecuteCommandAsync("external.action", "external.action", args).ConfigureAwait(false);

create.variant コマンド

using System.Globalization;
using Newtonsoft.Json.Linq;

var properties = new JObject(
new JProperty(
"property1", 
new JObject(
new JProperty("value", "some"),
new JProperty("required", true))),
new JProperty(
"property2",
new JObject(
new JProperty("value", "else"),
new JProperty("required", false)))
);

var relations = new JObject(
new JProperty(
"relation1", 
new JObject(
new JProperty("links", new JArray(new[] { 12345, 67890 })),
new JProperty("required", false))),
new JProperty(
"relation2",
new JObject(
new JProperty("links", new JArray(new[] { 87654 })),
new JProperty("required", false)))
);

JObject args = new JObject(
new JProperty("source_entity_id", 45678),
new JProperty("copy_profile_id", 23456),
new JProperty("properties_overrides", properties),
new JProperty("relations_overrides", relations));

await MClient.Commands.ExecuteCommandAsync("derivatives", "create.variant", args).ConfigureAwait(false);
この記事を改善するための提案がある場合は、 お知らせください!