本頁面由英文在 AI 協助下翻譯而成。若兩者有出入,請以英文版本為準。
DESCRIBE
描述資源或資源上的特定方法。
另請參閱: [ StackQL 資源階層 ]
語法
describeStatement::=
DESCRIBE [ METHOD ] [ EXTENDED ] <multipartIdentifier> ;
DESC [ EXTENDED ] <multipartIdentifier> ;
描述資源時,DESC 可作為 DESCRIBE 的別名;DESCRIBE METHOD 則必須使用完整關鍵字。
回應
- DESCRIBE
- DESCRIBE METHOD
| 資料行 | 描述 |
|---|---|
name | 欄位名稱 |
type | 資料型別(string、integer、boolean、number、object、array) |
description | 欄位描述(若提供 EXTENDED) |
| 資料行 | 描述 |
|---|---|
name | 欄位名稱 |
type | 資料型別(string、integer、boolean、number、object、array) |
param_type | input_required、input_optional 或 output |
shape | 描述該欄位的 JSON 物件:type,以及適用時的 format、enum、wire_name(API 本身對該欄位使用的名稱)、child_count、properties、required 和 items。巢狀物件和陣列會展開一層;schema 還有後續層級的節點會帶有 truncated: true。使用 EXTENDED 時也包含 description |
description | 欄位描述(若提供 EXTENDED) |
範例
基本 DESCRIBE 陳述式
從已驗證的工作階段執行基本 DESCRIBE 陳述式,以列出資源中的欄位。
-- Show the available fields in a Compute Engine resource
DESCRIBE google.compute.instances;
延伸 DESCRIBE 陳述式
從已驗證的工作階段執行延伸 DESCRIBE 陳述式,以列出資源中的欄位及其描述。
-- Show the available fields in a Compute Engine resource
DESCRIBE EXTENDED google.compute.instances;
DESC 別名
DESC 是對資源使用 DESCRIBE 時的簡寫,可搭配或不搭配 EXTENDED。凡是 DESCRIBE 被視為唯讀陳述式之處,它也同樣被視為唯讀陳述式,包括 read_only 和 safe 模式下 MCP 伺服器的 run_select_query 工具。
-- Same result as DESCRIBE EXTENDED google.compute.instances
DESC EXTENDED google.compute.instances;
基本 DESCRIBE METHOD 陳述式
檢查資源上的單一方法。結果包含輸入參數和回應欄位,第一層巢狀結構則呈現在 shape 資料行中。從 v1.1.959 起,DESCRIBE METHOD 會傳回這種具型別的淺層檢視,並且只讀取已驗證的 Provider 文件,不會呼叫任何 Provider API;EXTENDED 會加入描述。
-- Show the inputs and outputs for the buckets.get method
DESCRIBE METHOD google.storage.buckets.get;
延伸 DESCRIBE METHOD 陳述式
執行延伸 DESCRIBE METHOD 陳述式,除了 shape 之外,也包含每個欄位的描述。
-- Show inputs, outputs, and descriptions for the buckets.insert method
DESCRIBE METHOD EXTENDED google.storage.buckets.insert;
探索 INSERT 承載
DESCRIBE METHOD 是探索 INSERT(或任何變更方法)接受哪些欄位的標準方式。要求本文欄位會以 data__ 輸入的形式出現,並帶有其宣告的型別,而 shape 資料行會顯示每個巢狀欄位的第一層。
-- See what google.compute.instances.insert accepts
DESCRIBE METHOD EXTENDED google.compute.instances.insert;
深入查看巢狀欄位
stackql_preview.metadata.method_fields 關聯會傳回相同的檢視,並可控制展開方式,而且不需要 --preview 旗標。它接受 SELECT *,並需要 provider、service、resource 和 method 述詞。選用的述詞包括 path(要展開之欄位的點分隔路徑,會隱含地周遊陣列項目)、depth(要展開的層數,預設為 1,最大為 32)、descriptions(設為 'true' 以包含描述)、param_type(input、output、input_required 或 input_optional)和 include_global(設為 'true' 以包含 Provider 文件全域宣告的選用查詢參數)。一個檢視最多包含 4096 個 schema 節點。MCP describe_method 工具接受相同的選項。
下列查詢將執行個體網路介面的存取設定展開兩層並包含描述,且只顯示要求輸入:
SELECT * FROM stackql_preview.metadata.method_fields
WHERE provider = 'google' AND service = 'compute'
AND resource = 'instances' AND method = 'insert'
AND path = 'data__networkInterfaces.accessConfigs'
AND depth = 2 AND descriptions = 'true' AND param_type = 'input';