14262: Tests for setting and checking container tokens.
[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         CreatedAt            time.Time            `json:"created_at"`
13         Command              []string             `json:"command"`
14         ContainerImage       string               `json:"container_image"`
15         Cwd                  string               `json:"cwd"`
16         Environment          map[string]string    `json:"environment"`
17         LockedByUUID         string               `json:"locked_by_uuid"`
18         Mounts               map[string]Mount     `json:"mounts"`
19         Output               string               `json:"output"`
20         OutputPath           string               `json:"output_path"`
21         Priority             int                  `json:"priority"`
22         RuntimeConstraints   RuntimeConstraints   `json:"runtime_constraints"`
23         State                ContainerState       `json:"state"`
24         SchedulingParameters SchedulingParameters `json:"scheduling_parameters"`
25 }
26
27 // Container is an arvados#container resource.
28 type ContainerRequest struct {
29         UUID                    string                 `json:"uuid"`
30         OwnerUUID               string                 `json:"owner_uuid"`
31         CreatedAt               time.Time              `json:"created_at"`
32         ModifiedByClientUUID    string                 `json:"modified_by_client_uuid"`
33         ModifiedByUserUUID      string                 `json:"modified_by_user_uuid"`
34         ModifiedAt              time.Time              `json:"modified_at"`
35         Href                    string                 `json:"href"`
36         Kind                    string                 `json:"kind"`
37         Etag                    string                 `json:"etag"`
38         Name                    string                 `json:"name"`
39         Description             string                 `json:"description"`
40         Properties              map[string]interface{} `json:"properties"`
41         State                   ContainerRequestState  `json:"state"`
42         RequestingContainerUUID string                 `json:"requesting_container_uuid"`
43         ContainerUUID           string                 `json:"container_uuid"`
44         ContainerCountMax       int                    `json:"container_count_max"`
45         Mounts                  map[string]Mount       `json:"mounts"`
46         RuntimeConstraints      RuntimeConstraints     `json:"runtime_constraints"`
47         SchedulingParameters    SchedulingParameters   `json:"scheduling_parameters"`
48         ContainerImage          string                 `json:"container_image"`
49         Environment             map[string]string      `json:"environment"`
50         Cwd                     string                 `json:"cwd"`
51         Command                 []string               `json:"command"`
52         OutputPath              string                 `json:"output_path"`
53         OutputName              string                 `json:"output_name"`
54         OutputTTL               int                    `json:"output_ttl"`
55         Priority                int                    `json:"priority"`
56         UseExisting             bool                   `json:"use_existing"`
57         LogUUID                 string                 `json:"log_uuid"`
58         OutputUUID              string                 `json:"output_uuid"`
59         RuntimeToken            string                 `json:"runtime_token"`
60 }
61
62 // Mount is special behavior to attach to a filesystem path or device.
63 type Mount struct {
64         Kind              string      `json:"kind"`
65         Writable          bool        `json:"writable"`
66         PortableDataHash  string      `json:"portable_data_hash"`
67         UUID              string      `json:"uuid"`
68         DeviceType        string      `json:"device_type"`
69         Path              string      `json:"path"`
70         Content           interface{} `json:"content"`
71         ExcludeFromOutput bool        `json:"exclude_from_output"`
72         Capacity          int64       `json:"capacity"`
73         Commit            string      `json:"commit"`          // only if kind=="git_tree"
74         RepositoryName    string      `json:"repository_name"` // only if kind=="git_tree"
75         GitURL            string      `json:"git_url"`         // only if kind=="git_tree"
76 }
77
78 // RuntimeConstraints specify a container's compute resources (RAM,
79 // CPU) and network connectivity.
80 type RuntimeConstraints struct {
81         API          *bool
82         RAM          int64 `json:"ram"`
83         VCPUs        int   `json:"vcpus"`
84         KeepCacheRAM int64 `json:"keep_cache_ram"`
85 }
86
87 // SchedulingParameters specify a container's scheduling parameters
88 // such as Partitions
89 type SchedulingParameters struct {
90         Partitions  []string `json:"partitions"`
91         Preemptible bool     `json:"preemptible"`
92         MaxRunTime  int      `json:"max_run_time"`
93 }
94
95 // ContainerList is an arvados#containerList resource.
96 type ContainerList struct {
97         Items          []Container `json:"items"`
98         ItemsAvailable int         `json:"items_available"`
99         Offset         int         `json:"offset"`
100         Limit          int         `json:"limit"`
101 }
102
103 // ContainerState is a string corresponding to a valid Container state.
104 type ContainerState string
105
106 const (
107         ContainerStateQueued    = ContainerState("Queued")
108         ContainerStateLocked    = ContainerState("Locked")
109         ContainerStateRunning   = ContainerState("Running")
110         ContainerStateComplete  = ContainerState("Complete")
111         ContainerStateCancelled = ContainerState("Cancelled")
112 )
113
114 // ContainerState is a string corresponding to a valid Container state.
115 type ContainerRequestState string
116
117 const (
118         ContainerRequestStateUncomitted = ContainerState("Uncommitted")
119         ContainerRequestStateCommitted  = ContainerState("Committed")
120         ContainerRequestStateFinal      = ContainerState("Final")
121 )