Merge branch '21941-keep-web-link' refs #21941
[arvados.git] / sdk / go / arvados / container.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import "time"
8
9 // Container is an arvados#container resource.
10 type Container struct {
11         UUID                      string                 `json:"uuid"`
12         Etag                      string                 `json:"etag"`
13         CreatedAt                 time.Time              `json:"created_at"`
14         ModifiedByUserUUID        string                 `json:"modified_by_user_uuid"`
15         ModifiedAt                time.Time              `json:"modified_at"`
16         Command                   []string               `json:"command"`
17         ContainerImage            string                 `json:"container_image"`
18         Cwd                       string                 `json:"cwd"`
19         Environment               map[string]string      `json:"environment"`
20         LockedByUUID              string                 `json:"locked_by_uuid"`
21         LockCount                 int                    `json:"lock_count"`
22         Mounts                    map[string]Mount       `json:"mounts"`
23         Output                    string                 `json:"output"`
24         OutputPath                string                 `json:"output_path"`
25         OutputGlob                []string               `json:"output_glob"`
26         Priority                  int64                  `json:"priority"`
27         RuntimeConstraints        RuntimeConstraints     `json:"runtime_constraints"`
28         State                     ContainerState         `json:"state"`
29         SchedulingParameters      SchedulingParameters   `json:"scheduling_parameters"`
30         ExitCode                  int                    `json:"exit_code"`
31         RuntimeStatus             map[string]interface{} `json:"runtime_status"`
32         StartedAt                 *time.Time             `json:"started_at"`  // nil if not yet started
33         FinishedAt                *time.Time             `json:"finished_at"` // nil if not yet finished
34         GatewayAddress            string                 `json:"gateway_address"`
35         InteractiveSessionStarted bool                   `json:"interactive_session_started"`
36         OutputStorageClasses      []string               `json:"output_storage_classes"`
37         RuntimeUserUUID           string                 `json:"runtime_user_uuid"`
38         RuntimeAuthScopes         []string               `json:"runtime_auth_scopes"`
39         RuntimeToken              string                 `json:"runtime_token"`
40         AuthUUID                  string                 `json:"auth_uuid"`
41         Log                       string                 `json:"log"`
42         Cost                      float64                `json:"cost"`
43         SubrequestsCost           float64                `json:"subrequests_cost"`
44 }
45
46 // ContainerRequest is an arvados#container_request resource.
47 type ContainerRequest struct {
48         UUID                    string                 `json:"uuid"`
49         OwnerUUID               string                 `json:"owner_uuid"`
50         CreatedAt               time.Time              `json:"created_at"`
51         ModifiedByUserUUID      string                 `json:"modified_by_user_uuid"`
52         ModifiedAt              time.Time              `json:"modified_at"`
53         Href                    string                 `json:"href"`
54         Etag                    string                 `json:"etag"`
55         Name                    string                 `json:"name"`
56         Description             string                 `json:"description"`
57         Properties              map[string]interface{} `json:"properties"`
58         State                   ContainerRequestState  `json:"state"`
59         RequestingContainerUUID string                 `json:"requesting_container_uuid"`
60         ContainerUUID           string                 `json:"container_uuid"`
61         ContainerCountMax       int                    `json:"container_count_max"`
62         Mounts                  map[string]Mount       `json:"mounts"`
63         RuntimeConstraints      RuntimeConstraints     `json:"runtime_constraints"`
64         SchedulingParameters    SchedulingParameters   `json:"scheduling_parameters"`
65         ContainerImage          string                 `json:"container_image"`
66         Environment             map[string]string      `json:"environment"`
67         Cwd                     string                 `json:"cwd"`
68         Command                 []string               `json:"command"`
69         OutputPath              string                 `json:"output_path"`
70         OutputGlob              []string               `json:"output_glob"`
71         OutputName              string                 `json:"output_name"`
72         OutputTTL               int                    `json:"output_ttl"`
73         Priority                int                    `json:"priority"`
74         UseExisting             bool                   `json:"use_existing"`
75         LogUUID                 string                 `json:"log_uuid"`
76         OutputUUID              string                 `json:"output_uuid"`
77         RuntimeToken            string                 `json:"runtime_token"`
78         ExpiresAt               time.Time              `json:"expires_at"`
79         Filters                 []Filter               `json:"filters"`
80         ContainerCount          int                    `json:"container_count"`
81         OutputStorageClasses    []string               `json:"output_storage_classes"`
82         OutputProperties        map[string]interface{} `json:"output_properties"`
83         CumulativeCost          float64                `json:"cumulative_cost"`
84 }
85
86 // Mount is special behavior to attach to a filesystem path or device.
87 type Mount struct {
88         Kind              string      `json:"kind"`
89         Writable          bool        `json:"writable"`
90         PortableDataHash  string      `json:"portable_data_hash"`
91         UUID              string      `json:"uuid"`
92         DeviceType        string      `json:"device_type"`
93         Path              string      `json:"path"`
94         Content           interface{} `json:"content"`
95         ExcludeFromOutput bool        `json:"exclude_from_output"`
96         Capacity          int64       `json:"capacity"`
97 }
98
99 type CUDARuntimeConstraints struct {
100         DriverVersion      string `json:"driver_version"`
101         HardwareCapability string `json:"hardware_capability"`
102         DeviceCount        int    `json:"device_count"`
103 }
104
105 // RuntimeConstraints specify a container's compute resources (RAM,
106 // CPU) and network connectivity.
107 type RuntimeConstraints struct {
108         API           bool                   `json:"API"`
109         RAM           int64                  `json:"ram"`
110         VCPUs         int                    `json:"vcpus"`
111         KeepCacheRAM  int64                  `json:"keep_cache_ram"`
112         KeepCacheDisk int64                  `json:"keep_cache_disk"`
113         CUDA          CUDARuntimeConstraints `json:"cuda"`
114 }
115
116 // SchedulingParameters specify a container's scheduling parameters
117 // such as Partitions
118 type SchedulingParameters struct {
119         Partitions  []string `json:"partitions"`
120         Preemptible bool     `json:"preemptible"`
121         MaxRunTime  int      `json:"max_run_time"`
122         Supervisor  bool     `json:"supervisor"`
123 }
124
125 // ContainerList is an arvados#containerList resource.
126 type ContainerList struct {
127         Items          []Container `json:"items"`
128         ItemsAvailable int         `json:"items_available"`
129         Offset         int         `json:"offset"`
130         Limit          int         `json:"limit"`
131 }
132
133 // ContainerRequestList is an arvados#containerRequestList resource.
134 type ContainerRequestList struct {
135         Items          []ContainerRequest `json:"items"`
136         ItemsAvailable int                `json:"items_available"`
137         Offset         int                `json:"offset"`
138         Limit          int                `json:"limit"`
139 }
140
141 // ContainerState is a string corresponding to a valid Container state.
142 type ContainerState string
143
144 const (
145         ContainerStateQueued    = ContainerState("Queued")
146         ContainerStateLocked    = ContainerState("Locked")
147         ContainerStateRunning   = ContainerState("Running")
148         ContainerStateComplete  = ContainerState("Complete")
149         ContainerStateCancelled = ContainerState("Cancelled")
150 )
151
152 // ContainerRequestState is a string corresponding to a valid Container Request state.
153 type ContainerRequestState string
154
155 const (
156         ContainerRequestStateUncomitted = ContainerRequestState("Uncommitted")
157         ContainerRequestStateCommitted  = ContainerRequestState("Committed")
158         ContainerRequestStateFinal      = ContainerRequestState("Final")
159 )
160
161 type ContainerStatus struct {
162         UUID             string         `json:"uuid"`
163         State            ContainerState `json:"container_state"`
164         SchedulingStatus string         `json:"scheduling_status"`
165 }