すべてのメタデータテンプレートのリストの取得

ガイド メタデータ メタデータテンプレート すべてのメタデータテンプレートのリストの取得

すべてのメタデータテンプレートのリストの取得

enterpriseスコープまたはglobalスコープのメタデータテンプレートのリストを取得できます。

グローバルテンプレートのリストを取得

すべてのグローバルメタデータテンプレートのリストを取得するには、GET /metadata_templates/global APIエンドポイントを呼び出します。

cURL
curl -i -X GET "https://api.box.com/2.0/metadata_templates/global" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
BoxEnterpriseMetadataTemplateCollection<BoxMetadataTemplate> templates = await client.MetadataManager
    .GetEnterpriseMetadataAsync("global");
Java
Iterable<MetadataTemplate> templates = MetadataTemplate.getEnterpriseMetadataTemplates('global', api);
for (MetadataTemplate templateInfo : templates) {
    // Do something with the metadata template.
}
Python
templates = client.get_metadata_templates(scope='global)
for template in templates:
    print(f'Metadata template {template.templateKey} is in global scope')
Node
client.metadata.getTemplates('global')
	.then(templates => {
		// ...
	});
iOS
let iterator = client.metadata.listEnterpriseTemplates(scope: "global")
iterator.next { results in
    switch results {
    case let .success(page):
        for template in page.entries {
            print("Template name: \(template.displayName)")
        }

    case let .failure(error):
        print(error)
    }
}

このAPIは、Boxによって作成され、すべての会社が使用できるすべてのメタデータテンプレートのリストを返します。

現在の会社のテンプレートのリストを取得

現在の会社内で使用するために作成されたすべてのメタデータテンプレートのリストを取得するには、GET /metadata_templates/enterprise APIエンドポイントを呼び出します。

cURL
curl -i -X GET "https://api.box.com/2.0/metadata_templates/enterprise" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
.NET
BoxEnterpriseMetadataTemplateCollection<BoxMetadataTemplate> templates = await client.MetadataManager
    .GetEnterpriseMetadataAsync();
Java
Iterable<MetadataTemplate> templates = MetadataTemplate.getEnterpriseMetadataTemplates(api);
for (MetadataTemplate templateInfo : templates) {
    // Do something with the metadata template.
}
Python
templates = client.get_metadata_templates()
for template in templates:
    print(f'Metadata template {template.templateKey} is in enterprise scope')
Node
client.metadata.getTemplates('enterprise')
	.then(templates => {
		/* templates -> {
			limit: 100,
			entries: 
			[ { templateKey: 'documentFlow',
				scope: 'enterprise_12345',
				displayName: 'Document Flow',
				hidden: false,
				fields: 
					[ { type: 'string',
						key: 'currentDocumentStage',
						displayName: 'Current Document Stage',
						hidden: false }
					{ type: 'string',
						key: 'needsApprovalFrom',
						displayName: 'Needs Approval From',
						hidden: false },
					{ type: 'string',
						key: 'nextDocumentStage',
						displayName: 'Next Document Stage',
						hidden: false }
					{ type: 'float',
						key: 'maximumDaysAllowedInCurrentStage',
						displayName: 'Maximum Days Allowed In Current Stage',
						hidden: false }
				{ templateKey: 'marketingCollateral',
				scope: 'enterprise_12345',
				displayName: 'Marketing Collateral',
				hidden: false,
				fields: 
					[ { type: 'string',
						key: 'audience1',
						displayName: 'Audience',
						hidden: false },
					{ type: 'string',
						key: 'previousState',
						displayName: 'Previous State',
						hidden: false } ] },
				{ templateKey: 'productInfo',
				scope: 'enterprise_12345',
				displayName: 'Product Info',
				hidden: false,
				fields: 
					[ { type: 'float',
						key: 'skuNumber',
						displayName: 'SKU Number',
						hidden: false },
					{ type: 'enum',
						key: 'department',
						displayName: 'Department',
						hidden: false,
						options: 
						[ { key: 'Beauty' },
						{ key: 'Shoes' },
						{ key: 'Accessories' },
						{ key: 'Clothing' },
						{ key: 'Handbags' },
						{ key: 'Bedding' },
						{ key: 'Watches' } ] },
					{ type: 'date',
						key: 'displayDate',
						displayName: 'Display Date',
						hidden: false } ] } ],
			next_marker: null,
			prev_marker: null }
		*/
	});
iOS
let iterator = client.metadata.listEnterpriseTemplates(scope: "enterprise")
iterator.next { results in
    switch results {
    case let .success(page):
        for template in page.entries {
            print("Template name: \(template.displayName)")
        }

    case let .failure(error):
        print(error)
    }
}

このAPIは、この会社によって作成されたすべてのメタデータテンプレートのリストを返します。これらのテンプレートは、この会社内のファイルにのみ適用できます。

ページ割り

このAPIでは、マーカーベースのページ割りが使用されており、レスポンスの本文で、より多くのテンプレートを使用できることを示すnext_marker値を返すことができます。