10181: Merge branch 'master' into 10181-incremental-log
[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 }
60
61 // Mount is special behavior to attach to a filesystem path or device.
62 type Mount struct {
63         Kind              string      `json:"kind"`
64         Writable          bool        `json:"writable"`
65         PortableDataHash  string      `json:"portable_data_hash"`
66         UUID              string      `json:"uuid"`
67         DeviceType        string      `json:"device_type"`
68         Path              string      `json:"path"`
69         Content           interface{} `json:"content"`
70         ExcludeFromOutput bool        `json:"exclude_from_output"`
71         Capacity          int64       `json:"capacity"`
72         Commit            string      `json:"commit"`          // only if kind=="git_tree"
73         RepositoryName    string      `json:"repository_name"` // only if kind=="git_tree"
74         GitURL            string      `json:"git_url"`         // only if kind=="git_tree"
75 }
76
77 // RuntimeConstraints specify a container's compute resources (RAM,
78 // CPU) and network connectivity.
79 type RuntimeConstraints struct {
80         API          *bool
81         RAM          int64 `json:"ram"`
82         VCPUs        int   `json:"vcpus"`
83         KeepCacheRAM int64 `json:"keep_cache_ram"`
84 }
85
86 // SchedulingParameters specify a container's scheduling parameters
87 // such as Partitions
88 type SchedulingParameters struct {
89         Partitions  []string `json:"partitions"`
90         Preemptible bool     `json:"preemptible"`
91         MaxRunTime  int      `json:"max_run_time"`
92 }
93
94 // ContainerList is an arvados#containerList resource.
95 type ContainerList struct {
96         Items          []Container `json:"items"`
97         ItemsAvailable int         `json:"items_available"`
98         Offset         int         `json:"offset"`
99         Limit          int         `json:"limit"`
100 }
101
102 // ContainerState is a string corresponding to a valid Container state.
103 type ContainerState string
104
105 const (
106         ContainerStateQueued    = ContainerState("Queued")
107         ContainerStateLocked    = ContainerState("Locked")
108         ContainerStateRunning   = ContainerState("Running")
109         ContainerStateComplete  = ContainerState("Complete")
110         ContainerStateCancelled = ContainerState("Cancelled")
111 )
112
113 // ContainerState is a string corresponding to a valid Container state.
114 type ContainerRequestState string
115
116 const (
117         ContainerRequestStateUncomitted = ContainerState("Uncommitted")
118         ContainerRequestStateCommitted  = ContainerState("Committed")
119         ContainerRequestStateFinal      = ContainerState("Final")
120 )