<div dir="ltr"><div dir="ltr"><div>Hi Juan,</div><div><br></div><div>One option is to filter by a repo like this:</div><div style="margin-left:40px"><span style="font-family:courier new,monospace">export PUBLICATION_HREF=$(http :24817/pulp/api/v3/publications/rpm/rpm/ | jq -r '.results[] | select(.repository_version|test("'$REPO_HREF'.")) | ._href')</span></div><span style="font-family:courier new,monospace"></span><div><br></div><div><font face="arial,sans-serif">I'll update the docs, thank you for the catch!</font></div><div><font face="arial,sans-serif"></font><br></div><div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Also, to get the href at the creation of the publication will
      help and reduce the number of task.</div></blockquote><div>You get only a task href at the time of API call that creates a publication because this call is asynchronous, so it's not possible to return href of a publication right away.</div><div>You can query the task and whenever it's complete you can get a publication href, e.g.</div><div style="margin-left:40px"><span style="font-family:courier new,monospace">export PUBLICATION_HREF=$(http :24817/pulp/api/v3/tasks/2c83e17f-f036-44f8-a753-e5e78a79984b/ | jq -r '.created_resources[]' | grep publications)</span></div><div style="margin-left:40px"><span style="font-family:courier new,monospace"><br></span></div><span style="font-family:courier new,monospace"><span style="font-family:arial,sans-serif">grep part is not necessary here since no other resources are getting created with that call but for other calls there can be multiple resources created within one task.</span><br></span></div><div><span style="font-family:courier new,monospace"><br></span></div><div><span style="font-family:arial,sans-serif">Hope that helps,</span></div><div><span style="font-family:courier new,monospace"><span style="font-family:arial,sans-serif">Tanya</span><br></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, May 25, 2019 at 12:47 AM Juan Cabrera <<a href="mailto:juan.cabrera@unamur.be">juan.cabrera@unamur.be</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p>I have problems getting the HREF of a rpm publication to create
      the distribution.<br>
    </p>
    <p>in
<a class="gmail-m_-4929220032549553174moz-txt-link-freetext" href="https://pulp-rpm.readthedocs.io/en/latest/workflows/create_sync_publish.html#create-a-publication" target="_blank">https://pulp-rpm.readthedocs.io/en/latest/workflows/create_sync_publish.html#create-a-publication</a></p>
    <p>the command <br>
    </p>
    <p><tt>$ http POST :24817/pulp/api/v3/publications/rpm/rpm/
        repository=$REPO_HREF</tt></p>
    <p>Do not return the _href as in the example. It only gives the
      task, so I can not get the HREF at this moment.<br>
    </p>
    <p>The next command <br>
    </p>
    <p><code class="gmail-m_-4929220032549553174docutils gmail-m_-4929220032549553174literal gmail-notranslate"><span class="gmail-m_-4929220032549553174pre">$</span>
        <span class="gmail-m_-4929220032549553174pre">export</span> <span class="gmail-m_-4929220032549553174pre">PUBLICATION_HREF=$(http</span>
        <span class="gmail-m_-4929220032549553174pre">:24817/pulp/api/v3/publications/rpm/rpm/</span>
        <span class="gmail-m_-4929220032549553174pre">|</span> <span class="gmail-m_-4929220032549553174pre">jq</span> <span class="gmail-m_-4929220032549553174pre">-r</span> <span class="gmail-m_-4929220032549553174pre">'.results[]</span> <span class="gmail-m_-4929220032549553174pre">|</span> <span class="gmail-m_-4929220032549553174pre">._href')</span></code></p>
    <p>only works when there is only one publication. When there is more
      than one it gives</p>
    <p><tt>[vagrant@dev-pulp-server ~]$ http
        $PORT/pulp/api/v3/publications/rpm/rpm/  | jq -r '.results[] |
        ._href'</tt><tt><br>
      </tt><tt>/pulp/api/v3/publications/rpm/rpm/2e145f16-95a8-4a35-b1e4-ecdb5c4c08d9/</tt><tt><br>
      </tt><tt>/pulp/api/v3/publications/rpm/rpm/fa835dfb-4c33-4d7c-a74b-b0065b43ca97/</tt><tt><br>
      </tt><tt>/pulp/api/v3/publications/rpm/rpm/d4cd0d2a-9979-43af-8bcb-e4d24f8f6ebd/</tt><tt><br>
      </tt><tt>/pulp/api/v3/publications/rpm/rpm/c81bf7e3-8ba4-4642-a64f-fae6a73bc9ed/</tt><br>
    </p>
    <p>In previous release the selection was done with the publisher
      href</p>
    <p><code class="gmail-m_-4929220032549553174docutils gmail-m_-4929220032549553174literal gmail-notranslate"><span class="gmail-m_-4929220032549553174pre">$</span>
        <span class="gmail-m_-4929220032549553174pre">export</span> <span class="gmail-m_-4929220032549553174pre">PUBLICATION_HREF=$(http</span>
        <span class="gmail-m_-4929220032549553174pre">:24817/pulp/api/v3/publications/rpm/rpm/</span>
        <span class="gmail-m_-4929220032549553174pre">|</span> <span class="gmail-m_-4929220032549553174pre">jq</span> <span class="gmail-m_-4929220032549553174pre">-r</span> <span class="gmail-m_-4929220032549553174pre">'.results[]</span> <span class="gmail-m_-4929220032549553174pre">|</span> <span class="gmail-m_-4929220032549553174pre">._href')</span></code></p>
    <p>It will be interesting to have a query parameter that allow to
      select a publication based, for example, on the repository.<br>
    </p>
    <p><a class="gmail-m_-4929220032549553174moz-txt-link-freetext" href="https://pulp-rpm.readthedocs.io/en/latest/restapi.html#operation/publications_rpm_rpm_list" target="_blank">https://pulp-rpm.readthedocs.io/en/latest/restapi.html#operation/publications_rpm_rpm_list</a></p>
    <p>Also, to get the href at the creation of the publication will
      help and reduce the number of task.<br>
    </p>
    <p>Is there any solution I did not see?</p>
    <p>Juan<br>
    </p>
    <div class="gmail-m_-4929220032549553174moz-signature">-- <br>
      <div style="font-family:Verdana,Helvetica,Arial,sans-serif;font-size:8pt;font-weight:normal;color:rgb(97,99,101)"> <img src="cid:16af8e57f7bf9ec99bb1" style="display: block; margin: 1em 0em;">
        <p style="margin:1em"> <span style="font-weight:bold">Juan
            CABRERA</span><br>
          <span style="color:rgb(105,190,40)">Correspondant informatique</span><br>
          <span>Département de Mathématiques</span> </p>
        <p style="margin:1em">
          <span style="font-weight:bold">T.</span> 081724919<br>
          <a style="color:rgb(105,190,40)" href="mailto:juan.cabrera@unamur.be" target="_blank">juan.cabrera@unamur.be</a><br>
          <a style="color:rgb(105,190,40)" href="http://staff.unamur.be/jbcabrer" target="_blank">http://staff.unamur.be/jbcabrer</a>
        </p>
        <p style="margin:1em"> <span style="font-weight:bold;font-size:8pt">Université de Namur ASBL</span><br>
          <span>Rue de Bruxelles 61 - 5000 Namur</span><br>
          <span>Belgique</span><br>
        </p>
        <p style="margin:1em;font-size:6pt;color:rgb(105,190,40)"> <span>Let’s
            respect the environment together.</span><br>
          <span style="font-weight:bold">Only print this message if
            necessary!</span><br>
        </p>
      </div>
    </div>
  </div>

_______________________________________________<br>
Pulp-list mailing list<br>
<a href="mailto:Pulp-list@redhat.com" target="_blank">Pulp-list@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-list" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pulp-list</a></blockquote></div></div>