简体   繁体   中英

Getting license details in Artifactory REST API

I would like to get Long Name , URL , and Notes field values from Artifactory REST API. These fields are available when I'm editing from the web app.

When I hit the License Search API , I'm not getting these fields. Is there any API that I can use to get more details?

License Search API result

{"uri": "http://localhost:8080/artifactory/api/storage/libs-release-local/org/acme/lib/ver/lib-ver.jar",
"license": "lgplv2",
"found": "",
"status": "approved"}

Webapp showing field values

Artifactory编辑许可

There is no 'official' REST API call for that.

First of all, a feature request is welcome.

Second, you can create such an endpoint yourself by implementing an execution user plugin . It will, probably, require a usage of internal APIs, so be prepared to test and maintain it after upgrades. Here's a good example to get you started (also uses the exact service you'll need).

As far as I can see, and as of Artifactory 5.4.6, there is no official API to retrieve global license information (ie what is shown in the Admin > Configuration > Licenses page ).

If you are ready to rely on undocumented API, you could call directly the "License export" web service. It is undocumented / not public and outputs XML but that seems to work well enough.

curl -u "admin:password" -X GET "http://yourartifactory/artifactory/ui/licenseexport"

will output

<?xml version='1.0' encoding='UTF-8'?>
<licenses>
  <licenses>
    <license>
      <name>AFL-3.0</name>
      <longName>The Academic Free License 3.0</longName>
      <url>http://www.opensource.org/licenses/afl-3.0.php</url>
      <regexp>((.*)(academic)(.*)|(AFL)+(.*))(3)(.*)</regexp>
      <approved>false</approved>
      <unknown>false</unknown>
      <validLicense>false</validLicense>
      <found>false</found>
      <notFound>false</notFound>
      <notSearched>false</notSearched>
    </license>
    <license>
    [...]
    </license>
  </licenses>
</licenses>

By combining the outputs from licenseexport and the licensesearch, you could script whatever you need...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM