文章
· 八月 5, 2022 阅读大约需 3 分钟

第十八章 源代码文件 REST API 教程(三)

第十八章 源代码文件 REST API 教程(三)

编译文件

Compile 方法编译传入 JSON 数组中名称指定的源代码文件。例如,要编译 xyz.mac,请发布以下内容:

http://localhost:52773/api/atelier/v1/INVENTORY/action/compile

使用以下 JSON 消息:

["xyz.mac"]

该方法返回:

{
  "status": {
    "errors": [],
    "summary": ""
  },
  "console": [
    "",
    "Compilation started on 08/14/2016 15:25:20 with qualifiers 'cuk'",
    "xyz.int is up to date. Compile of this item skipped.",
    "Compilation finished successfully in 0.008s."
  ],
  "result": {
    "content": []
  }
}

对于一些源代码文件,例如类,Compile 在返回的内容中返回存储信息。

删除文件

DeleteDoc 方法删除 URL 中指定的文件。 DeleteDoc 方法与 GetDoc 方法具有相同的 URL,只是使用 HTTP Delete 方法而不是 Get 方法。要删除 xyz.mac,请使用以下 URL 发出 HTTP DELETE 请求:

http://localhost:52773/api/atelier/v1/INVENTORY/doc/xyz.mac

Delete 方法返回以下 JSON 消息:

{
  "status": {
    "errors": [],
    "summary": ""
  },
  "console": [],
  "result": {
    "name": "xyz.mac",
    "db": "INVENTORYR",
    "ts": "",
    "cat": "RTN",
    "status": "",
    "enc": false,
    "flags": 0,
    "content": []
  }
}

删除文件后,时间戳 ts 的值为 ""(空字符串)。

执行 SQL 查询

Query 方法对任何 IRIS 数据库执行 SQL 查询。例如,如果应用程序想要向用户显示一个 IRIS 角色列表,它可以通过以下调用发现它们:

POST http://localhost:52773/api/atelier/v1/%25SYS/action/query

使用传入 JSON 消息中指定的 SQL 查询:

{"query": "SELECT ID,Description FROM Security.Roles"}

此调用在结果内容元素中以 JSON 形式返回 SQL 查询的结果。

{
  "status": {
    "errors": [],
    "summary": ""
  },
  "console": [],
  "result": {
    "content": [
      {
        "ID": "%all",
        "Description": "The Super-User Role"
      },
      {
        "ID": "%db_%default",
        "Description": "R/W access for this resource"
      },
      ... 
      {
        "ID": "%sqltunetable",
        "Description": "Role for use by tunetable to sample tables irrespective of row level security"
      }
    ]
  }
}

可以使用 Query 方法来查询 中的任何表。例如,以下调用在名为 SAMPLES 的命名空间中查询名为 Sample.Person 的表。

POST http://localhost:52773/api/atelier/v1/SAMPLES/action/query
{"query": "SELECT Age,SSN,Home_City,Name FROM Sample.Person WHERE Age = 25"}

此调用返回:

{
  "status": {
    "errors": [],
    "summary": ""
  },
  "console": [],
  "result": {
    "content": [
      {
        "Age": 25,
        "SSN": "230-78-7696",
        "Home_City": "Larchmont",
        "Name": "DeLillo,Jose F."
      },
      {
        "Age": 25,
        "SSN": "546-73-7513",
        "Home_City": "Gansevoort",
        "Name": "Klingman,Thelma H."
      }
    ]
  }
}
讨论 (0)1
登录或注册以继续