|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../core/resource'; |
| 4 | +import { PagePromise, SessionsPage, type SessionsPageParams } from '../core/pagination'; |
| 5 | +import { RequestOptions } from '../internal/request-options'; |
| 6 | + |
| 7 | +export class Usage extends APIResource { |
| 8 | + /** |
| 9 | + * Lists environment sessions within a specified date range. |
| 10 | + * |
| 11 | + * Returns a list of environment sessions that were active within the specified |
| 12 | + * date range. |
| 13 | + */ |
| 14 | + listEnvironmentSessions( |
| 15 | + params: UsageListEnvironmentSessionsParams, |
| 16 | + options?: RequestOptions, |
| 17 | + ): PagePromise<EnvironmentSessionsSessionsPage, EnvironmentSession> { |
| 18 | + const { token, pageSize, ...body } = params; |
| 19 | + return this._client.getAPIList( |
| 20 | + '/gitpod.v1.UsageService/ListEnvironmentSessions', |
| 21 | + SessionsPage<EnvironmentSession>, |
| 22 | + { query: { token, pageSize }, body, method: 'post', ...options }, |
| 23 | + ); |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +export type EnvironmentSessionsSessionsPage = SessionsPage<EnvironmentSession>; |
| 28 | + |
| 29 | +export interface EnvironmentSession { |
| 30 | + /** |
| 31 | + * Environment session ID. |
| 32 | + */ |
| 33 | + id?: string; |
| 34 | + |
| 35 | + /** |
| 36 | + * Time when the session was created. |
| 37 | + */ |
| 38 | + createdAt?: string; |
| 39 | + |
| 40 | + /** |
| 41 | + * Environment class ID associated with the session. |
| 42 | + */ |
| 43 | + environmentClassId?: string; |
| 44 | + |
| 45 | + /** |
| 46 | + * Environment ID associated with the session. |
| 47 | + */ |
| 48 | + environmentId?: string; |
| 49 | + |
| 50 | + /** |
| 51 | + * Project ID associated with the session. |
| 52 | + */ |
| 53 | + projectId?: string; |
| 54 | + |
| 55 | + /** |
| 56 | + * Runner ID associated with the session. |
| 57 | + */ |
| 58 | + runnerId?: string; |
| 59 | + |
| 60 | + /** |
| 61 | + * Time when the session was stopped. |
| 62 | + */ |
| 63 | + stoppedAt?: string; |
| 64 | + |
| 65 | + /** |
| 66 | + * User ID who created the session. |
| 67 | + */ |
| 68 | + userId?: string; |
| 69 | +} |
| 70 | + |
| 71 | +export interface UsageListEnvironmentSessionsParams extends SessionsPageParams { |
| 72 | + /** |
| 73 | + * Body param: Filter options. |
| 74 | + */ |
| 75 | + filter?: UsageListEnvironmentSessionsParams.Filter; |
| 76 | + |
| 77 | + /** |
| 78 | + * Body param: Pagination options. |
| 79 | + */ |
| 80 | + pagination?: UsageListEnvironmentSessionsParams.Pagination; |
| 81 | +} |
| 82 | + |
| 83 | +export namespace UsageListEnvironmentSessionsParams { |
| 84 | + /** |
| 85 | + * Filter options. |
| 86 | + */ |
| 87 | + export interface Filter { |
| 88 | + /** |
| 89 | + * Date range to query sessions within. |
| 90 | + */ |
| 91 | + dateRange: Filter.DateRange; |
| 92 | + |
| 93 | + /** |
| 94 | + * Optional project ID to filter sessions by. |
| 95 | + */ |
| 96 | + projectId?: string; |
| 97 | + } |
| 98 | + |
| 99 | + export namespace Filter { |
| 100 | + /** |
| 101 | + * Date range to query sessions within. |
| 102 | + */ |
| 103 | + export interface DateRange { |
| 104 | + /** |
| 105 | + * End time of the date range (exclusive). |
| 106 | + */ |
| 107 | + endTime: string; |
| 108 | + |
| 109 | + /** |
| 110 | + * Start time of the date range (inclusive). |
| 111 | + */ |
| 112 | + startTime: string; |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Pagination options. |
| 118 | + */ |
| 119 | + export interface Pagination { |
| 120 | + /** |
| 121 | + * Token for the next set of results that was returned as next_token of a |
| 122 | + * PaginationResponse |
| 123 | + */ |
| 124 | + token?: string; |
| 125 | + |
| 126 | + /** |
| 127 | + * Page size is the maximum number of results to retrieve per page. Defaults to 25. |
| 128 | + * Maximum 100. |
| 129 | + */ |
| 130 | + pageSize?: number; |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +export declare namespace Usage { |
| 135 | + export { |
| 136 | + type EnvironmentSession as EnvironmentSession, |
| 137 | + type EnvironmentSessionsSessionsPage as EnvironmentSessionsSessionsPage, |
| 138 | + type UsageListEnvironmentSessionsParams as UsageListEnvironmentSessionsParams, |
| 139 | + }; |
| 140 | +} |
0 commit comments