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