godo.Registry.ListGarbageCollections()

Generated on 5 Nov 2026 from godo version v1.236.0

Usage

client.Registry.ListGarbageCollections(ctx context.Context, registry string, opts *godo.ListOptions) ([]*godo.GarbageCollection, *godo.Response, error)

Description

ListGarbageCollections retrieves all garbage collections (active and inactive) for the specified registry.

This method sends a GET request to /v2/registry/{}/garbage-collections.

Parameters

registry string required
opts *godo.ListOptions

Fields of godo.ListOptions

ListOptions specifies the optional parameters to various List methods that support pagination.

Page int

For paginated result sets, page of results to retrieve.

PerPage int

For paginated result sets, the number of results to include per page.

WithProjects bool

Whether App responses should include project_id fields. The field will be empty if false or if omitted. (ListApps)

Deployed bool

This parameter is used to only list agents that are deployed in the response.

PublicOnly bool

This parameter is used to include models that are publicly available.

Usecases []string

This parameter is used to include models according to the use cases.

Returns

[]*godo.GarbageCollection
*godo.Response

The HTTP response, with pagination Links, Meta, and Rate limit information.

error

Non-nil when the request fails. API errors are returned as *godo.ErrorResponse.

Fields of godo.GarbageCollection

GarbageCollection represents a garbage collection.

UUID string

JSON key: uuid

RegistryName string

JSON key: registry_name

Status string

JSON key: status

Type godo.GarbageCollectionType

JSON key: type

CreatedAt time.Time

JSON key: created_at

UpdatedAt time.Time

JSON key: updated_at

BlobsDeleted uint64

JSON key: blobs_deleted

FreedBytes uint64

JSON key: freed_bytes

Request Sample

Show Request Sample
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/digitalocean/godo"
)

func main() {
	client := godo.NewFromToken(os.Getenv("DIGITALOCEAN_TOKEN"))
	ctx := context.TODO()

	result, _, err := client.Registry.ListGarbageCollections(ctx, "<your-registry>", &godo.ListOptions{Page: 1, PerPage: 50})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", result)
}

Pagination

This method returns one page of results. Response.Links carries the pagination state; loop until IsLastPage reports true.

Show Pagination Sample
opt := &godo.ListOptions{Page: 1, PerPage: 50}
for {
	items, resp, err := client.Registry.ListGarbageCollections(ctx, "<your-registry>", opt)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", items)

	if resp.Links == nil || resp.Links.IsLastPage() {
		break
	}
	page, err := resp.Links.CurrentPage()
	if err != nil {
		log.Fatal(err)
	}
	opt.Page = page + 1
}

Response Example

Show Response Example
{
  "garbage_collections": [
    {
      "uuid": "eff0feee-49c7-4e8f-ba5c-a320c109c8a8",
      "registry_name": "example",
      "status": "requested",
      "created_at": "2020-10-30T21:03:24.000Z",
      "updated_at": "2020-10-30T21:03:44.000Z",
      "blobs_deleted": 42,
      "freed_bytes": 667
    }
  ],
  "meta": {
    "total": 1
  }
}

More Information

See GET /v2/registry/{}/garbage-collections in the API reference for additional detail on responses, headers, parameters, and more.

See the Go package documentation for the source of this method.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.