[Pulp-list] Make a selection in a GET call
Juan Cabrera
juan.cabrera at unamur.be
Fri May 24 14:34:22 UTC 2019
In fact, I found a better way. I use the pkgId which equals to sha256
and I use it already to get the artifact href.
An intermediate way I used, is a regex to get name,version,release and
arch to generate the query
- hosts: localhost
vars:
package: mailcap-2.1.41-2.el7.noarch.rpm
tasks:
- name: set fac
set_fact:
pkg: "{{ package | regex_findall('(.*)-(.*)-(.*)\\.(.*)\\.rpm')
| flatten }}"
- debug:
msg: "name={{ pkg[0] }}&version={{pkg[1]}}&release={{ pkg[2]
}}&arch={{ pkg[3] }}"
But still it could be useful to query the package name. I opened a issue
https://pulp.plan.io/issues/4879
Juan
On 24/05/19 14:33, David Davis wrote:
> The 'name' field in your case would be mailcap. We don't expose the
> file name of the package or allow users to filter on it but we should.
> Would you mind filing an issue?
>
> https://pulp.plan.io/projects/pulp_rpm/issues/new
>
> By the way, thanks for using the RC. Your feedback is very much
> appreciated.
>
> David
>
>
> On Fri, May 24, 2019 at 5:41 AM Juan Cabrera <juan.cabrera at unamur.be
> <mailto:juan.cabrera at unamur.be>> wrote:
>
> I think I found the answer, name,.version,.release,.arch comes
> from the package name.
>
> Is not more easy to find a content HREF looking for the
> .location_href instead of .name,.version,.release,.arch ?
>
> http
> "$PORT/pulp/api/v3/content/rpm/packages/?name=mailcap&version=2.1.41&release=2.el7&arch=noarch"
>
> I prefer the query version than using jq
>
> http $PORT/pulp/api/v3/content/rpm/packages/ | jq -r '.results[] |
> select( .location_href == "mailcap-2.1.41-2.el7.noarch.rpm")'
>
> There could be a limitation when there are to much contents
> because the pagination prevents to look for all contents.
>
> Juan
>
> On 24/05/19 11:08, Juan Cabrera wrote:
>>
>> Hi,
>>
>> I realized that I can get the href of an artifact selecting its
>> sha512 in the URI path.
>>
>> https://docs.pulpproject.org/en/3.0/nightly/restapi.html#operation/artifacts_list
>>
>> This simplifies the use of jq as I get directly the good artifact.
>>
>> [vagrant at dev-pulp-server ~]$ http
>> $PORT/pulp/api/v3/artifacts/?sha512=9df10268233e243ef8b6c0fc9fea6452bf81eea8b2627c90d0a652304b5acf05e4996768c68adb4f6d224a369e7f3b6cf77d3fb62b5989bfce3fa94d46ce9ec7
>> HTTP/1.1 200 OK
>> Allow: GET, POST, HEAD, OPTIONS
>> Connection: close
>> Content-Length: 745
>> Content-Type: application/json
>> Date: Fri, 24 May 2019 08:39:23 GMT
>> Server: gunicorn/19.9.0
>> Vary: Accept, Cookie
>> X-Frame-Options: SAMEORIGIN
>>
>> {
>> "count": 1,
>> "next": null,
>> "previous": null,
>> "results": [
>> {
>> "_created": "2019-05-24T08:08:58.445890Z",
>> "_href":
>> "/pulp/api/v3/artifacts/aaefcc88-9bb7-4a70-9e98-19e039b0f95e/",
>> "file":
>> "artifact/5b/6b81a0bbe944ab393ea8dea0ab2cf906a1f6fd81ad139efd125d2454752780",
>>
>> "md5": "0011ff65d03dde05b4370f7879b4bd0c",
>> "sha1": "db05ead3a760d5906ea5cd9c1e4d713379785b90",
>> "sha224":
>> "6b0da4b1ef04d25344d924f8785cc5fd34f7b58554fbcc9e902fb1a3",
>> "sha256":
>> "5b6b81a0bbe944ab393ea8dea0ab2cf906a1f6fd81ad139efd125d2454752780",
>> "sha384":
>> "8598ba74004db73b0f02bed5bc5ef0313539123986be910fda07187bff926a7d608dcec1815a7a248cd8a218dc53f6ad",
>>
>> "sha512":
>> "9df10268233e243ef8b6c0fc9fea6452bf81eea8b2627c90d0a652304b5acf05e4996768c68adb4f6d224a369e7f3b6cf77d3fb62b5989bfce3fa94d46ce9ec7",
>>
>> "size": 31264
>> }
>> ]
>> }
>>
>> I see in
>> https://pulp-rpm.readthedocs.io/en/latest/restapi.html#operation/content_rpm_packages_list
>>
>> that there is a possible "name" query. But to what this query
>> corresponds?
>>
>> [vagrant at dev-pulp-server ~]$ http
>> $PORT/pulp/api/v3/content/rpm/packages/?name=mailcap-2.1.41-2.el7.noarch.rpm
>>
>> HTTP/1.1 200 OK
>> Allow: GET, POST, HEAD, OPTIONS
>> Connection: close
>> Content-Length: 52
>> Content-Type: application/json
>> Date: Fri, 24 May 2019 09:05:08 GMT
>> Server: gunicorn/19.9.0
>> Vary: Accept, Cookie
>> X-Frame-Options: SAMEORIGIN
>>
>> {
>> "count": 0,
>> "next": null,
>> "previous": null,
>> "results": []
>> }
>>
>> Sincerely
>>
>> Juan
>>
>> --
>>
>> Juan CABRERA
>> Correspondant informatique
>> Département de Mathématiques
>>
>> T. 081724919
>> juan.cabrera at unamur.be <mailto:juan.cabrera at unamur.be>
>> http://staff.unamur.be/jbcabrer
>>
>> Université de Namur ASBL
>> Rue de Bruxelles 61 - 5000 Namur
>> Belgique
>>
>> Let’s respect the environment together.
>> Only print this message if necessary!
>>
>>
>> _______________________________________________
>> Pulp-list mailing list
>> Pulp-list at redhat.com <mailto:Pulp-list at redhat.com>
>> https://www.redhat.com/mailman/listinfo/pulp-list
> --
>
> Juan CABRERA
> Correspondant informatique
> Département de Mathématiques
>
> T. 081724919
> juan.cabrera at unamur.be <mailto:juan.cabrera at unamur.be>
> http://staff.unamur.be/jbcabrer
>
> Université de Namur ASBL
> Rue de Bruxelles 61 - 5000 Namur
> Belgique
>
> Let’s respect the environment together.
> Only print this message if necessary!
>
> _______________________________________________
> Pulp-list mailing list
> Pulp-list at redhat.com <mailto:Pulp-list at redhat.com>
> https://www.redhat.com/mailman/listinfo/pulp-list
>
--
Juan CABRERA
Correspondant informatique
Département de Mathématiques
T. 081724919
juan.cabrera at unamur.be <mailto:juan.cabrera at unamur.be>
http://staff.unamur.be/jbcabrer
Université de Namur ASBL
Rue de Bruxelles 61 - 5000 Namur
Belgique
Let’s respect the environment together.
Only print this message if necessary!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-list/attachments/20190524/9917c12a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lofndhpfeinefpce.png
Type: image/png
Size: 9356 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/pulp-list/attachments/20190524/9917c12a/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: npcodcekphkjnald.png
Type: image/png
Size: 9356 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/pulp-list/attachments/20190524/9917c12a/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: liklgjnjlcbjmgbf.png
Type: image/png
Size: 9356 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/pulp-list/attachments/20190524/9917c12a/attachment-0002.png>
More information about the Pulp-list
mailing list