# How to get docker asset details ? (Last downloaded, Uploader)

**URL:** <https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987>\
**Category:** Sonatype Nexus Repository\
**Tags:** api\
**Created:** [November 20, 2019, 9:04am UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987 "2019-11-20T09:04:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ihlavaty.cz](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@ihlavaty.cz](https://community.sonatype.com/u/ihlavaty.cz)\
**Post date:** [November 20, 2019, 9:04am UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987/1 "2019-11-20T09:04:54Z")

</div>

Hello,  
I was trying to figure out how to get docker asset details which are normally visible via web UI, but using Nexus API…  
Particularly  
-Last downloaded  
-Uploader  
-Uploader’s IP Address  
-Blob created  
any ideas?  
_/service/rest/v1/assets/id - doesn’t show_  
_/service/rest/v1/components/id - doesn’t show_

---

<div class="post-metadata">

**Author:** ![rseddon](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/rseddon/32/341_2.png) [@rseddon](https://community.sonatype.com/u/rseddon)\
**Post date:** [November 20, 2019, 3:53pm UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987/2 "2019-11-20T15:53:21Z")

</div>

This can be done with [groovy scripting](https://help.sonatype.com/display/NXRM3/Script+API)…

```auto
import org.sonatype.nexus.repository.storage.StorageFacet
import org.sonatype.nexus.repository.Repository
import org.sonatype.nexus.repository.storage.Asset

repository.repositoryManager.browse().each { Repository repo ->
    StorageFacet storageFacet = repo.facet(StorageFacet)
    def tx = storageFacet.txSupplier().get()
    try {
        tx.begin()

        tx.browseAssets(tx.findBucket(repo)).each { Asset asset ->
            log.info(asset.attributes().get('content').get('etag'))
            log.info(asset.attributes().get('content').get('last_modified'))
        }
    } finally {
        tx.close()
    }
}

```

The attributes available can be found in the component detail UI.

Also see here:

> **[Nexus Repository 3 Groovy Script development environment setup](https://support.sonatype.com/hc/en-us/articles/115015812727-Nexus-Repository-3-Groovy-Script-development-environment-setup)**
>
>  
> Note: Groovy scripting is disabled by default for security reasons. Development work on the groovy API was halted, and it will eventually be fully deprecated.  Groovy scripting can also cause per...

> **[Groovy: Close those transactions, or else...](https://support.sonatype.com/hc/en-us/articles/115015847987-Groovy-Close-those-transactions-or-else)**
>
> See Nexus 3 Groovy Script development environment setup for tips on how to develop groovy scripts for Nexus 3.
> Warning:
> Do not try this in production.
> Warning:
> Do NOT run the example code below bef...

---

<div class="post-metadata">

**Author:** ![ihlavaty.cz](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@ihlavaty.cz](https://community.sonatype.com/u/ihlavaty.cz)\
**Post date:** [November 21, 2019, 7:45am UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987/3 "2019-11-21T07:45:22Z")

</div>

thanks Rich,  
It is unpleasant that these information are not available via API directly. I am building a python script for analyzing the repo for further advanced cleanup policies (using API for advanced cleanup policy is recommended by Sonatype) and I have to split the logic to groovy script and python ☹

---

<div class="post-metadata">

**Author:** ![ihlavaty.cz](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@ihlavaty.cz](https://community.sonatype.com/u/ihlavaty.cz)\
**Post date:** [November 21, 2019, 3:04pm UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987/4 "2019-11-21T15:04:35Z")

</div>

I am sorry, but the script is not working … ‘etag’ is allways null and ‘last\_modified’ is required with toString() method

```
2019-11-21 16:02:31,974+0100 INFO [quartz-3-thread-19] *SYSTEM org.sonatype.nexus.internal.script.ScriptTask - null
2019-11-21 16:02:31,974+0100 INFO [quartz-3-thread-19] *SYSTEM org.sonatype.nexus.internal.script.ScriptTask - Wed Oct 02 17:14:29 CEST 2019
```

---

<div class="post-metadata">

**Author:** ![rseddon](https://yyz1.discourse-cdn.com/flex047/user_avatar/community.sonatype.com/rseddon/32/341_2.png) [@rseddon](https://community.sonatype.com/u/rseddon)\
**Post date:** [November 21, 2019, 4:42pm UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987/5 "2019-11-21T16:42:26Z")

</div>

It’s just an example, check to see what attributes are available for the asset you are querying in the UI, and modify the script as needed.

---

<div class="post-metadata">

**Author:** ![ihlavaty.cz](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@ihlavaty.cz](https://community.sonatype.com/u/ihlavaty.cz)\
**Post date:** [November 22, 2019, 11:57am UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987/6 "2019-11-22T11:57:43Z")

</div>

> [@rseddon](#):
>
> vailable for the asset you are querying in the UI, and modify the script as needed.

Ok, I got, thanks … I am able to get sha256+last\_modified, but I cannot find last\_downloaded … I have tried to download components using groovy script, but it is also not in there… is there some doc where I can find object structure and class methods ? It is very hard to find in source code…

---

<div class="post-metadata">

**Author:** ![ihlavaty.cz](https://avatars.discourse-cdn.com/v4/letter/i/b4bc9f/32.png) [@ihlavaty.cz](https://community.sonatype.com/u/ihlavaty.cz)\
**Post date:** [November 22, 2019, 1:40pm UTC](https://community.sonatype.com/t/how-to-get-docker-asset-details-last-downloaded-uploader/2987/7 "2019-11-22T13:40:26Z")

</div>

I have just figured it out…  
There is much easier way of getting all necessary information,instead of going down through get() method - which may end in null.get() exception - use methods to access asset attributes directly… e.g.  
asset.lastDownloaded()  
asset.blobUpdated()  
[class definition](https://github.com/sonatype/nexus-public/blob/master/components/nexus-repository/src/main/java/org/sonatype/nexus/repository/storage/Asset.java)
