セルフサービスソースのソース仕様の設定(バッチSDK)
ソース仕様には、ソースのカテゴリ、ベータステータス、カタログアイコンに関する属性など、ソースに固有の情報が含まれます。また、URL パラメーター、コンテンツ、ヘッダー、スケジュールなどの便利な情報も含まれています。ソース仕様は、ベース接続からのソース接続を作成するために必要なパラメーターのスキーマも記述します。ソース接続を作成するには、スキーマが必要です。
完全に入力されたソース仕様の例については、付録を参照してください。
"sourceSpec": {
"attributes": {
"uiAttributes": {
"isSource": true,
"isPreview": true,
"isBeta": true,
"category": {
"key": "protocols"
},
"icon": {
"key": "genericRestIcon"
},
"description": {
"key": "genericRestDescription"
},
"label": {
"key": "genericRestLabel"
}
},
"spec": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"description": "Defines static and user input parameters to fetch resource values.",
"properties": {
"urlParams": {
"type": "object",
"properties": {
"host": {
"type": "string",
"description": "Enter resource url host path.",
"example": "https://{domain}.api.mailchimp.com"
},
"path": {
"type": "string",
"description": "Enter resource path",
"example": "/3.0/reports/campaignId/email-activity"
},
"method": {
"type": "string",
"description": "HTTP method type.",
"enum": [
"GET",
"POST"
]
},
"queryParams": {
"type": "object",
"description": "The query parameters in json format",
}
},
"required": [
"host",
"path",
"method"
]
},
"headerParams": {
"type": "object",
"description": "The header parameters in json format",
},
"contentPath": {
"type": "object",
"description": "The parameters required for main collection content.",
"properties": {
"path": {
"description": "The path to the main content.",
"type": "string",
"example": "$.emails"
},
"skipAttributes": {
"type": "array",
"description": "The list of attributes that needs to be skipped while fattening the array.",
"example": "[total_items]",
"items": {
"type": "string"
}
},
"keepAttributes": {
"type": "array",
"description": "The list of attributes that needs to be kept while fattening the array.",
"example": "[total_items]",
"items": {
"type": "string"
}
},
"overrideWrapperAttribute": {
"type": "string",
"description": "The new name to be used for the root content path node.",
"example": "email"
}
},
"required": [
"path"
]
},
"explodeEntityPath": {
"type": "object",
"description": "The parameters required for the sub-array content.",
"properties": {
"path": {
"description": "The path to the sub-array content.",
"type": "string",
"example": "$.email.activity"
},
"skipAttributes": {
"type": "array",
"description": "The list of attributes that needs to be skipped while fattening sub-array.",
"example": "[total_items]",
"items": {
"type": "string"
}
},
"keepAttributes": {
"type": "array",
"description": "The list of attributes that needs to be kept while fattening the sub-array.",
"example": "[total_items]",
"items": {
"type": "string"
}
},
"overrideWrapperAttribute": {
"type": "string",
"description": "The new name to be used for the root content path node.",
"example": "activity"
}
},
"required": [
"path"
]
},
"paginationParams": {
"type": "object",
"description": "The parameters required to fetch data using pagination.",
"properties": {
"type": {
"description": "The pagination fetch type.",
"type": "string",
"enum": [
"OFFSET",
"POINTER"
]
},
"limitName": {
"type": "string",
"description": "The limit property name",
"example": "limit or count"
},
"limitValue": {
"type": "integer",
"description": "The number of records to fetch per page.",
"example": "limit=10 or count=10"
},
"offsetName": {
"type": "string",
"description": "The offset property name",
"example": "offset"
},
"pointerPath": {
"type": "string",
"description": "The path to pointer property",
"example": "$.paging.next"
}
},
"required": [
"type",
"limitName",
"limitValue"
]
},
"scheduleParams": {
"type": "object",
"description": "The parameters required to fetch data for batch schedule.",
"properties": {
"scheduleStartParamName": {
"type": "string",
"description": "The order property name to get the order by date."
},
"scheduleEndParamName": {
"type": "string",
"description": "The order property name to get the order by date."
},
"scheduleStartParamFormat": {
"type": "string",
"description": "The order property name to get the order by date.",
"example": "yyyy-MM-ddTHH:mm:ssZ"
},
"scheduleEndParamFormat": {
"type": "string",
"description": "The order property name to get the order by date.",
"example": "yyyy-MM-ddTHH:mm:ssZ"
}
},
"required": [
"scheduleStartParamName",
"scheduleEndParamName"
]
}
},
"required": [
"urlParams",
"contentPath",
"paginationParams",
"scheduleParams"
]
}
},
}
sourceSpec.attributessourceSpec.attributes.uiAttributessourceSpec.attributes.uiAttributes.isPreviewtruefalse
sourceSpec.attributes.uiAttributes.isBetatruefalse
sourceSpec.attributes.uiAttributes.categoryadvertisingcrmcustomer successdatabaseecommercemarketing automationpaymentsprotocols
sourceSpec.attributes.uiAttributes.iconmailchimp-icon.svgsourceSpec.attributes.uiAttributes.descriptionsourceSpec.attributes.uiAttributes.labelsourceSpec.attributes.spec.properties.urlParamssourceSpec.attributes.spec.properties.urlParams.properties.path/3.0/reports/${campaignId}/email-activitysourceSpec.attributes.spec.properties.urlParams.properties.methodGET, POSTsourceSpec.attributes.spec.properties.urlParams.properties.queryParams${USER_PARAMETER}。"queryParams" : {"key" : "value", "key1" : "value1"} はソース URL に /?key=value&key1=value1 として追加されます。sourceSpec.attributes.spec.properties.spec.properties.headerParams"headerParams" : {"Content-Type" : "application/json", "x-api-key" : "key"}sourceSpec.attributes.spec.properties.bodyParamssourceSpec.attributes.spec.properties.contentPathsourceSpec.attributes.spec.properties.contentPath.path$.emailssourceSpec.attributes.spec.properties.contentPath.skipAttributes[total_items]sourceSpec.attributes.spec.properties.contentPath.keepAttributes[total_items]sourceSpec.attributes.spec.properties.contentPath.overrideWrapperAttributecontentPath で指定した属性名の値を上書きできます。emailsourceSpec.attributes.spec.properties.explodeEntityPathsourceSpec.attributes.spec.properties.explodeEntityPath.path$.email.activitysourceSpec.attributes.spec.properties.explodeEntityPath.skipAttributes[total_items]sourceSpec.attributes.spec.properties.explodeEntityPath.keepAttributes[total_items]sourceSpec.attributes.spec.properties.explodeEntityPath.overrideWrapperAttributeexplodeEntityPath で指定した属性名の値を上書きできます。activitysourceSpec.attributes.spec.properties.paginationParamssourceSpec.attributes.spec.properties.paginationParams.typeOFFSET:このページネーションタイプを使用すると、結果の配列を開始する場所のインデックスと、返される結果の上限数を指定することで、結果を解析できます。POINTER:このページネーションタイプを使用すると、リクエストと共に送信する必要がある特定の項目を、pointer変数を使用して指定することができます。ポインタの種類のページ設定には、次のページを指すペイロードのパスが必要です。CONTINUATION_TOKEN:このページ分割タイプを使用すると、クエリまたはヘッダーパラメーターを継続トークンで追加して、ソースから残りのリターンデータを取得できます。このリターンデータは、事前に決定された最大値のために最初に返されませんでした。PAGE:このページ分割タイプを使用すると、ページごとに戻り値データをトラバースするページングパラメーターを含むクエリパラメーターをページの0から追加できます。NONE:このページ分割タイプは、使用可能なページ分割タイプのいずれもサポートしていないソースに使用できます。 Pagination typeNONEは、リクエストの後に応答データ全体を返します。
sourceSpec.attributes.spec.properties.paginationParams.limitNamelimit または countsourceSpec.attributes.spec.properties.paginationParams.limitValuelimit=10 または count=10sourceSpec.attributes.spec.properties.paginationParams.offSetNameoffset に設定されている場合に必要です。offsetsourceSpec.attributes.spec.properties.paginationParams.pointerPathpointer に設定されている場合に必要です。pointersourceSpec.attributes.spec.properties.scheduleParamsstartTime および endTime が含まれます。いずれも使用することで、バッチ実行に特定の時間間隔を設定でき、これにより前のバッチ実行で取得されたレコードが再び取得されることがなくなります。sourceSpec.attributes.spec.properties.scheduleParams.scheduleStartParamNamesince_last_changedsourceSpec.attributes.spec.properties.scheduleParams.scheduleEndParamNamebefore_last_changedsourceSpec.attributes.spec.properties.scheduleParams.scheduleStartParamFormatscheduleStartParamName でサポートされる形式を定義します。yyyy-MM-ddTHH:mm:ssZsourceSpec.attributes.spec.properties.scheduleParams.scheduleEndParamFormatscheduleEndParamName でサポートされる形式を定義します。yyyy-MM-ddTHH:mm:ssZsourceSpec.spec.propertiesspec.propertiesを参照してください。その他のリソース appendix
次の節では、高度なスケジュール設定やカスタムスキーマなど、sourceSpecに対して実行できる追加の設定について説明します。
コンテンツパスの例 content-path
MailChimp Members 接続の仕様における contentPath プロパティのコンテンツの例を次に示します。
"contentPath": {
"path": "$.members",
"skipAttributes": [
"_links",
"total_items",
"list_id"
],
"overrideWrapperAttribute": "member"
}
spec.properties ユーザー入力の例 user-input
MailChimp Members 接続の仕様を使用したユーザー指定 spec.properties の例を次に示します。
この例では、listId は urlParams.path の一部として指定されています。listId を顧客から取得する必要がある場合は、それを spec.properties の一部として定義する必要があります。
"urlParams": {
"path": "/3.0/lists/${listId}/members",
"method": "GET"
}
"spec": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"description": "Define user input parameters to fetch resource values.",
"properties": {
"listId": {
"type": "string",
"description": "listId for which members need to fetch."
}
}
}
ソースの仕様の例 source-spec
MailChimp Members を使用した完全なソース仕様を次に示します。
"sourceSpec": {
"attributes": {
"uiAttributes": {
"isSource": true,
"isPreview": true,
"isBeta": true,
"category": {
"key": "marketingAutomation"
},
"icon": {
"key": "mailchimpMembersIcon"
},
"description": {
"key": "mailchimpMembersDescription"
},
"label": {
"key": "mailchimpMembersLabel"
}
},
"urlParams": {
"host": "https://{domain}.api.mailchimp.com",
"path": "/3.0/lists/${listId}/members",
"method": "GET"
},
"contentPath": {
"path": "$.members",
"skipAttributes": [
"_links",
"total_items",
"list_id"
],
"overrideWrapperAttribute": "member"
},
"paginationParams": {
"type": "OFFSET",
"limitName": "count",
"limitValue": "100",
"offSetName": "offset"
},
"scheduleParams": {
"scheduleStartParamName": "since_last_changed",
"scheduleEndParamName": "before_last_changed",
"scheduleStartParamFormat": "yyyy-MM-ddTHH:mm:ss:fffffffK",
"scheduleEndParamFormat": "yyyy-MM-ddTHH:mm:ss:fffffffK"
}
},
"spec": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"description": "Define user input parameters to fetch resource values.",
"properties": {
"listId": {
"type": "string",
"description": "listId for which members need to fetch."
}
}
}
}
ソースに対して異なるページネーションの種類を設定します pagination
次に、セルフサービスソース(バッチSDK)でサポートされているその他のページネーションタイプの例を示します。
このページネーションタイプでは、結果の配列の開始場所からインデックスを指定し、結果の返し数に制限を設けることで、結果を解析できます。 例:
| code language-json |
|---|
|
| table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 | |
|---|---|
| プロパティ | 説明 |
type |
データを返すために使用されるページネーションのタイプ。 |
limitName |
API が 1 ページで取得するレコードの数を指定できる制限の名前。 |
limitValue |
1 ページで取得するレコードの数。 |
offSetName |
オフセット属性名。 ページネーションタイプが offset に設定されている場合に必要です。 |
endConditionName |
次のHTTP リクエストでページネーション ループを終了する条件を示すユーザー定義の値。 終了条件を配置する属性名を指定する必要があります。 |
endConditionValue |
終了条件を配置する属性値。 |
このページ分割タイプを使用すると、pointer変数を使用して、リクエストで送信する必要がある特定の項目を指定できます。 ポインタの種類のページ設定には、次のページを指すペイロードのパスが必要です。 例:
| code language-json |
|---|
|
| table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 | |
|---|---|
| プロパティ | 説明 |
type |
データを返すために使用されるページネーションのタイプ。 |
limitName |
API が 1 ページで取得するレコードの数を指定できる制限の名前。 |
limitValue |
1 ページで取得するレコードの数。 |
pointerPath |
ポインターの属性名。 これには、次のページを指す属性へのjson パスが必要です。 |
ページネーションの継続トークンタイプは、1回の応答で返すことができる項目の最大数があらかじめ決められているため、返すことができなかった項目の存在を示す文字列トークンを返します。
ページ分割の継続トークンタイプをサポートするソースには、次のようなページ分割パラメーターがあります。
| code language-json |
|---|
|
| table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 | |
|---|---|
| プロパティ | 説明 |
type |
データを返すために使用されるページネーションのタイプ。 |
continuationTokenPath |
返される結果の次のページに移動するために、クエリパラメーターに追加する必要がある値。 |
parameterType |
parameterType プロパティは、parameterNameを追加する必要がある場所を定義します。 QUERYPARAM タイプを使用すると、クエリをparameterNameに追加できます。 HEADERPARAMを使用すると、ヘッダーリクエストにparameterNameを追加できます。 |
parameterName |
継続トークンの組み込みに使用されるパラメーターの名前。 形式は次のとおりです:{PARAMETER_NAME}={CONTINUATION_TOKEN}。 |
delayRequestMillis |
ページネーションのdelayRequestMillis プロパティを使用すると、ソースに対して行われたリクエストの割合を制御できます。 一部のソースでは、1分に実行できるリクエストの数に制限があります。 例えば、Zendeskのリクエスト数は1分あたり100件に制限されており、delayRequestMillisから850を定義すると、1分あたり100件のリクエスト数のしきい値を大幅に下回る、1分あたり約80件のリクエストで呼び出しを行うようにソースを設定できます。 |
次に、ページネーションの継続トークンタイプを使用して返される応答の例を示します。
| code language-json |
|---|
|
PAGE タイプのページネーションでは、0から始まるページ数で返されるデータをトラバースできます。 PAGE タイプのページネーションを使用する場合は、1つのページで指定されたレコード数を指定する必要があります。
| code language-json |
|---|
|
| table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2 6-row-2 7-row-2 layout-auto | |
|---|---|
| プロパティ | 説明 |
type |
データを返すために使用されるページネーションのタイプ。 |
limitName |
API が 1 ページで取得するレコードの数を指定できる制限の名前。 |
limitValue |
1 ページで取得するレコードの数。 |
initialPageIndex |
(オプション)最初のページインデックスは、ページネーションを開始するページ番号を定義します。 このフィールドは、ページネーションが0から始まらないソースに使用できます。 指定しない場合、最初のページインデックスはデフォルトで0になります。 このフィールドには整数が必要です。 |
endPageIndex |
(オプション)終了ページインデックスを使用すると、終了条件を設定し、ページネーションを停止できます。 このフィールドは、ページ分割を停止するデフォルトの終了条件が使用できない場合に使用できます。 このフィールドは、取り込むページ数または最後のページ番号が応答ヘッダーを通じて提供される場合にも使用できます。これは、PAGE形式のページネーションを使用する場合に一般的です。 終了ページインデックスの値は、最後のページ番号または応答ヘッダーの文字列型式の値のいずれかになります。 例えば、headers.x-pagecountを使用して、応答ヘッダーからx-pagecount値に終了ページインデックスを割り当てることができます。 注: x-pagecountは、一部のソースに対する必須の応答ヘッダーであり、取り込むページの数の値を保持します。 |
pageParamName |
戻り値データの異なるページをトラバースするために、クエリパラメーターに追加する必要があるパラメーターの名前。 例えば、https://abc.com?pageIndex=1は、APIのリターンペイロードの2番目のページを返します。 |
maximumRequest |
特定の増分実行に対してソースが実行できるリクエストの最大数。 現在のデフォルト制限は10000です。 |
NONE ページネーション タイプは、使用可能なページネーション タイプのいずれもサポートしていないソースに使用できます。 NONEのページネーション型を使用するソースは、GET リクエストが行われたときに、取得できるすべてのレコードを返すだけです。
| code language-json |
|---|
|
セルフサービスソースの高度なスケジューリング(バッチSDK)
高度なスケジューリングを使用して、ソースの増分スケジュールとバックフィルのスケジュールを設定します。 incremental プロパティでは、ソースが新しいレコードまたは変更されたレコードのみを取り込むスケジュールを設定できます。一方、backfill プロパティでは、履歴データを取り込むスケジュールを作成できます。
高度なスケジュール機能を使用すると、ソースに固有の式や関数を使用して、増分スケジュールやバックフィル スケジュールを設定できます。 次の例では、Zendesk ソースでは、増分スケジュールをtype:user updated > {START_TIME} updated < {END_TIME}形式で、バックフィルをtype:user updated < {END_TIME}形式で設定する必要があります。
"scheduleParams": {
"type": "ADVANCE",
"paramFormat": "yyyy-MM-ddTHH:mm:ssK",
"incremental": "type:user updated > {START_TIME} updated < {END_TIME}",
"backfill": "type:user updated < {END_TIME}"
}
scheduleParams.typeADVANCEに設定します。scheduleParams.paramFormatscheduleStartParamFormatおよびscheduleEndParamFormatの値と同じにすることができます。scheduleParams.incrementalscheduleParams.backfill高度なスケジュールを設定したら、特定のソースがサポートしているものに応じて、URL、本文、またはヘッダーのパラメーターのセクションでscheduleParamsを参照する必要があります。 次の例では、{SCHEDULE_QUERY}は、増分スケジュール式とバックフィル スケジュール式を使用する場所を指定するために使用されるプレースホルダーです。 Zendesk ソースの場合、queryはqueryParamsで高度なスケジュール設定を指定するために使用されます。
"urlParams": {
"path": "/api/v2/search/export@{if(empty(coalesce(pipeline()?.parameters?.ingestionStart,'')),'?query=type:user&filter[type]=user&','')}",
"method": "GET",
"queryParams": {
"query": "{SCHEDULE_QUERY}",
"filter[type]": "user"
}
}
カスタムスキーマを追加して、ソースの動的属性を定義します
カスタムスキーマをsourceSpecに含めることで、必要な動的属性を含め、ソースに必要なすべての属性を定義できます。 接続仕様の/connectionSpecs セクションでカスタムスキーマを指定しながら、Flow Service APIのsourceSpec エンドポイントに対してPUT リクエストを行うことで、ソースの対応する接続仕様を更新できます。
次に、ソースの接続仕様に追加できるカスタムスキーマの例を示します。
"schema": {
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"type": "object",
"properties": {
"organization_id": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
}
"active": {
"type": "boolean"
},
"created_at": {
"type": "string"
},
"email": {
"type": "string"
},
"iana_time_zone": {
"type": "string"
},
"id": {
"type": "integer"
},
"locale": {
"type": "string"
},
"locale_id": {
"type": "integer"
},
"moderator": {
"type": "boolean"
},
"name": {
"type": "string"
},
"only_private_comments": {
"type": "boolean"
},
"report_csv": {
"type": "boolean"
},
"restricted_agent": {
"type": "boolean"
},
"result_type": {
"type": "string"
},
"role": {
"type": "integer"
},
"shared": {
"type": "boolean"
},
"shared_agent": {
"type": "boolean"
},
"suspended": {
"type": "boolean"
},
"ticket_restriction": {
"type": "string"
},
"time_zone": {
"type": "string"
},
"two_factor_auth_enabled": {
"type": "boolean"
},
"updated_at": {
"type": "string"
},
"url": {
"type": "string"
},
"verified": {
"type": "boolean"
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
次の手順
ソースの仕様を入力したら、Experience Platformに統合するソースのエクスプローラーの仕様を設定します。 詳しくは、探索仕様の設定に関するドキュメントを参照してください。