Skip to content
Ona Docs

ListEnvironmentUsageRecords

client.Usage.ListEnvironmentRuntimeRecords(ctx, params) (*RecordsPage[EnvironmentUsageRecord], error)
POST/gitpod.v1.UsageService/ListEnvironmentUsageRecords

Lists completed environment runtime records within a specified date range.

Returns a list of environment runtime records that were completed within the specified date range. Records of currently running environments are not included.

Use this method to:

  • View environment runtime records
  • Filter by project
  • Create custom usage reports

Example

filter:
  projectId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
  dateRange:
    startTime: "2024-01-01T00:00:00Z"
    endTime: "2024-01-02T00:00:00Z"
pagination:
  pageSize: 100
ParametersExpand Collapse
params UsageListEnvironmentRuntimeRecordsParams
Token param.Field[string]Optional

Query param

PageSize param.Field[int64]Optional

Query param

maximum100
minimum0

Body param: Filter options.

DateRange UsageListEnvironmentRuntimeRecordsParamsFilterDateRange

Date range to query runtime records within.

EndTime Time

End time of the date range (exclusive).

formatdate-time
StartTime Time

Start time of the date range (inclusive).

formatdate-time
ProjectID stringOptional

Optional project ID to filter runtime records by.

ReturnsExpand Collapse
type EnvironmentUsageRecord struct{…}

EnvironmentUsageRecord represents a record of an environment from start to stop.

ID stringOptional

Environment usage record ID.

CreatedAt TimeOptional

Time when the environment was created.

formatdate-time
EnvironmentClassID stringOptional

Environment class ID associated with the record.

EnvironmentID stringOptional

Environment ID associated with the record.

ProjectID stringOptional

Project ID associated with the environment (if available).

RunnerID stringOptional

Runner ID associated with the environment.

StoppedAt TimeOptional

Time when the environment was stopped.

formatdate-time
UserID stringOptional

User ID is the ID of the user who created the environment associated with the record.

ListEnvironmentUsageRecords

package main

import (
  "context"
  "fmt"
  "time"

  "github.com/gitpod-io/gitpod-sdk-go"
  "github.com/gitpod-io/gitpod-sdk-go/option"
)

func main() {
  client := gitpod.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  page, err := client.Usage.ListEnvironmentRuntimeRecords(context.TODO(), gitpod.UsageListEnvironmentRuntimeRecordsParams{
    Filter: gitpod.F(gitpod.UsageListEnvironmentRuntimeRecordsParamsFilter{
      DateRange: gitpod.F(gitpod.UsageListEnvironmentRuntimeRecordsParamsFilterDateRange{
        EndTime: gitpod.F(time.Now()),
        StartTime: gitpod.F(time.Now()),
      }),
      ProjectID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
    }),
    Pagination: gitpod.F(gitpod.UsageListEnvironmentRuntimeRecordsParamsPagination{
      PageSize: gitpod.F(int64(100)),
    }),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "pagination": {
    "nextToken": "nextToken"
  },
  "records": [
    {
      "id": "id",
      "createdAt": "2019-12-27T18:11:19.117Z",
      "environmentClassId": "environmentClassId",
      "environmentId": "environmentId",
      "projectId": "projectId",
      "runnerId": "runnerId",
      "stoppedAt": "2019-12-27T18:11:19.117Z",
      "userId": "userId"
    }
  ]
}
Returns Examples
{
  "pagination": {
    "nextToken": "nextToken"
  },
  "records": [
    {
      "id": "id",
      "createdAt": "2019-12-27T18:11:19.117Z",
      "environmentClassId": "environmentClassId",
      "environmentId": "environmentId",
      "projectId": "projectId",
      "runnerId": "runnerId",
      "stoppedAt": "2019-12-27T18:11:19.117Z",
      "userId": "userId"
    }
  ]
}