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