对象属性的JFrog Artifactory API查询不返回请求的详细信息

时间:2018-05-07 00:31:10

标签: rest docker artifactory attached-properties

我正在请求docker artifact的标签属性,也许url不正确?我得到响应对象(json)但不包括标签属性。代码示例:

  response = Net::HTTP.get_with_headers("http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json;docker.label.com.company.info.build='*'", 
                          {'Authorization' => 'Bearer <REDACTED>'})
  if response.code.to_s == "200"
    puts ("Artifactory response "+ response.body)
    puts ("response object: "+response.inspect())
  else
    puts ("Artifactory request returned "+response.code.to_s)
  end

Connecting to artifactory
Artifactory response {
  "repo" : "dockerv2-local",
  "path" : "/anonymizer/functional/manifest.json",
  "created" : "2018-03-14T14:52:22.681-07:00",
  "createdBy" : "build",
  "lastModified" : "2018-03-15T15:52:34.225-07:00",
  "modifiedBy" : "build",
  "lastUpdated" : "2018-03-15T15:52:34.225-07:00",
  "downloadUri" : "http://myrepo:8081/artifactory/dockerv2-local/anonymizer/functional/manifest.json",
  "mimeType" : "application/json",
  "size" : "1580",
  "checksums" : {
    "sha1" : "bf2a1f85c7ab8cec14b64d172b7fdaf420804fcb",
    "md5" : "9c1bbfc77e2f44d96255f7c1f99d2e8d",
    "sha256" : "53e56b21197c57d8ea9838df7cffb3d8f33cd714998d620efd8a34ba5a7e33c0"
  },
  "originalChecksums" : {
    "sha256" : "53e56b21197c57d8ea9838df7cffb3d8f33cd714998d620efd8a34ba5a7e33c0"
  },
  "uri" : "http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json"
}
response object: #<Net::HTTPOK 200 OK readbody=true>

1 个答案:

答案 0 :(得分:1)

如果我理解正确,您希望获得manifest.json文件的属性,特别是“docker.label.com.company.info.build”。

从查看命令:

response = Net::HTTP.get_with_headers("http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json;docker.label.com.company.info.build='*'", 

您似乎使用分号来获取属性,这不是正确的方法。正如您在此REST API中看到的,为了使用get属性,您应该使用&符号,因此您的命令应如下所示:

response = Net::HTTP.get_with_headers("http://myrepo:8081/artifactory/api/storage/dockerv2-local/anonymizer/functional/manifest.json&docker.label.com.company.info.build='*'",