1package containerinstance 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "encoding/json" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/date" 24 "github.com/Azure/go-autorest/autorest/to" 25 "net/http" 26) 27 28// ContainerGroupNetworkProtocol enumerates the values for container group network protocol. 29type ContainerGroupNetworkProtocol string 30 31const ( 32 // TCP ... 33 TCP ContainerGroupNetworkProtocol = "TCP" 34 // UDP ... 35 UDP ContainerGroupNetworkProtocol = "UDP" 36) 37 38// PossibleContainerGroupNetworkProtocolValues returns an array of possible values for the ContainerGroupNetworkProtocol const type. 39func PossibleContainerGroupNetworkProtocolValues() []ContainerGroupNetworkProtocol { 40 return []ContainerGroupNetworkProtocol{TCP, UDP} 41} 42 43// ContainerGroupRestartPolicy enumerates the values for container group restart policy. 44type ContainerGroupRestartPolicy string 45 46const ( 47 // Always ... 48 Always ContainerGroupRestartPolicy = "Always" 49 // Never ... 50 Never ContainerGroupRestartPolicy = "Never" 51 // OnFailure ... 52 OnFailure ContainerGroupRestartPolicy = "OnFailure" 53) 54 55// PossibleContainerGroupRestartPolicyValues returns an array of possible values for the ContainerGroupRestartPolicy const type. 56func PossibleContainerGroupRestartPolicyValues() []ContainerGroupRestartPolicy { 57 return []ContainerGroupRestartPolicy{Always, Never, OnFailure} 58} 59 60// ContainerNetworkProtocol enumerates the values for container network protocol. 61type ContainerNetworkProtocol string 62 63const ( 64 // ContainerNetworkProtocolTCP ... 65 ContainerNetworkProtocolTCP ContainerNetworkProtocol = "TCP" 66 // ContainerNetworkProtocolUDP ... 67 ContainerNetworkProtocolUDP ContainerNetworkProtocol = "UDP" 68) 69 70// PossibleContainerNetworkProtocolValues returns an array of possible values for the ContainerNetworkProtocol const type. 71func PossibleContainerNetworkProtocolValues() []ContainerNetworkProtocol { 72 return []ContainerNetworkProtocol{ContainerNetworkProtocolTCP, ContainerNetworkProtocolUDP} 73} 74 75// OperatingSystemTypes enumerates the values for operating system types. 76type OperatingSystemTypes string 77 78const ( 79 // Linux ... 80 Linux OperatingSystemTypes = "Linux" 81 // Windows ... 82 Windows OperatingSystemTypes = "Windows" 83) 84 85// PossibleOperatingSystemTypesValues returns an array of possible values for the OperatingSystemTypes const type. 86func PossibleOperatingSystemTypesValues() []OperatingSystemTypes { 87 return []OperatingSystemTypes{Linux, Windows} 88} 89 90// OperationsOrigin enumerates the values for operations origin. 91type OperationsOrigin string 92 93const ( 94 // System ... 95 System OperationsOrigin = "System" 96 // User ... 97 User OperationsOrigin = "User" 98) 99 100// PossibleOperationsOriginValues returns an array of possible values for the OperationsOrigin const type. 101func PossibleOperationsOriginValues() []OperationsOrigin { 102 return []OperationsOrigin{System, User} 103} 104 105// AzureFileVolume the properties of the Azure File volume. Azure File shares are mounted as volumes. 106type AzureFileVolume struct { 107 // ShareName - The name of the Azure File share to be mounted as a volume. 108 ShareName *string `json:"shareName,omitempty"` 109 // ReadOnly - The flag indicating whether the Azure File shared mounted as a volume is read-only. 110 ReadOnly *bool `json:"readOnly,omitempty"` 111 // StorageAccountName - The name of the storage account that contains the Azure File share. 112 StorageAccountName *string `json:"storageAccountName,omitempty"` 113 // StorageAccountKey - The storage account access key used to access the Azure File share. 114 StorageAccountKey *string `json:"storageAccountKey,omitempty"` 115} 116 117// Container a container instance. 118type Container struct { 119 // Name - The user-provided name of the container instance. 120 Name *string `json:"name,omitempty"` 121 // ContainerProperties - The properties of the container instance. 122 *ContainerProperties `json:"properties,omitempty"` 123} 124 125// MarshalJSON is the custom marshaler for Container. 126func (c Container) MarshalJSON() ([]byte, error) { 127 objectMap := make(map[string]interface{}) 128 if c.Name != nil { 129 objectMap["name"] = c.Name 130 } 131 if c.ContainerProperties != nil { 132 objectMap["properties"] = c.ContainerProperties 133 } 134 return json.Marshal(objectMap) 135} 136 137// UnmarshalJSON is the custom unmarshaler for Container struct. 138func (c *Container) UnmarshalJSON(body []byte) error { 139 var m map[string]*json.RawMessage 140 err := json.Unmarshal(body, &m) 141 if err != nil { 142 return err 143 } 144 for k, v := range m { 145 switch k { 146 case "name": 147 if v != nil { 148 var name string 149 err = json.Unmarshal(*v, &name) 150 if err != nil { 151 return err 152 } 153 c.Name = &name 154 } 155 case "properties": 156 if v != nil { 157 var containerProperties ContainerProperties 158 err = json.Unmarshal(*v, &containerProperties) 159 if err != nil { 160 return err 161 } 162 c.ContainerProperties = &containerProperties 163 } 164 } 165 } 166 167 return nil 168} 169 170// ContainerGroup a container group. 171type ContainerGroup struct { 172 autorest.Response `json:"-"` 173 *ContainerGroupProperties `json:"properties,omitempty"` 174 // ID - The resource id. 175 ID *string `json:"id,omitempty"` 176 // Name - The resource name. 177 Name *string `json:"name,omitempty"` 178 // Type - The resource type. 179 Type *string `json:"type,omitempty"` 180 // Location - The resource location. 181 Location *string `json:"location,omitempty"` 182 // Tags - The resource tags. 183 Tags map[string]*string `json:"tags"` 184} 185 186// MarshalJSON is the custom marshaler for ContainerGroup. 187func (cg ContainerGroup) MarshalJSON() ([]byte, error) { 188 objectMap := make(map[string]interface{}) 189 if cg.ContainerGroupProperties != nil { 190 objectMap["properties"] = cg.ContainerGroupProperties 191 } 192 if cg.ID != nil { 193 objectMap["id"] = cg.ID 194 } 195 if cg.Name != nil { 196 objectMap["name"] = cg.Name 197 } 198 if cg.Type != nil { 199 objectMap["type"] = cg.Type 200 } 201 if cg.Location != nil { 202 objectMap["location"] = cg.Location 203 } 204 if cg.Tags != nil { 205 objectMap["tags"] = cg.Tags 206 } 207 return json.Marshal(objectMap) 208} 209 210// UnmarshalJSON is the custom unmarshaler for ContainerGroup struct. 211func (cg *ContainerGroup) UnmarshalJSON(body []byte) error { 212 var m map[string]*json.RawMessage 213 err := json.Unmarshal(body, &m) 214 if err != nil { 215 return err 216 } 217 for k, v := range m { 218 switch k { 219 case "properties": 220 if v != nil { 221 var containerGroupProperties ContainerGroupProperties 222 err = json.Unmarshal(*v, &containerGroupProperties) 223 if err != nil { 224 return err 225 } 226 cg.ContainerGroupProperties = &containerGroupProperties 227 } 228 case "id": 229 if v != nil { 230 var ID string 231 err = json.Unmarshal(*v, &ID) 232 if err != nil { 233 return err 234 } 235 cg.ID = &ID 236 } 237 case "name": 238 if v != nil { 239 var name string 240 err = json.Unmarshal(*v, &name) 241 if err != nil { 242 return err 243 } 244 cg.Name = &name 245 } 246 case "type": 247 if v != nil { 248 var typeVar string 249 err = json.Unmarshal(*v, &typeVar) 250 if err != nil { 251 return err 252 } 253 cg.Type = &typeVar 254 } 255 case "location": 256 if v != nil { 257 var location string 258 err = json.Unmarshal(*v, &location) 259 if err != nil { 260 return err 261 } 262 cg.Location = &location 263 } 264 case "tags": 265 if v != nil { 266 var tags map[string]*string 267 err = json.Unmarshal(*v, &tags) 268 if err != nil { 269 return err 270 } 271 cg.Tags = tags 272 } 273 } 274 } 275 276 return nil 277} 278 279// ContainerGroupListResult the container group list response that contains the container group properties. 280type ContainerGroupListResult struct { 281 autorest.Response `json:"-"` 282 // Value - The list of container groups. 283 Value *[]ContainerGroup `json:"value,omitempty"` 284 // NextLink - The URI to fetch the next page of container groups. 285 NextLink *string `json:"nextLink,omitempty"` 286} 287 288// ContainerGroupListResultIterator provides access to a complete listing of ContainerGroup values. 289type ContainerGroupListResultIterator struct { 290 i int 291 page ContainerGroupListResultPage 292} 293 294// Next advances to the next value. If there was an error making 295// the request the iterator does not advance and the error is returned. 296func (iter *ContainerGroupListResultIterator) Next() error { 297 iter.i++ 298 if iter.i < len(iter.page.Values()) { 299 return nil 300 } 301 err := iter.page.Next() 302 if err != nil { 303 iter.i-- 304 return err 305 } 306 iter.i = 0 307 return nil 308} 309 310// NotDone returns true if the enumeration should be started or is not yet complete. 311func (iter ContainerGroupListResultIterator) NotDone() bool { 312 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 313} 314 315// Response returns the raw server response from the last page request. 316func (iter ContainerGroupListResultIterator) Response() ContainerGroupListResult { 317 return iter.page.Response() 318} 319 320// Value returns the current value or a zero-initialized value if the 321// iterator has advanced beyond the end of the collection. 322func (iter ContainerGroupListResultIterator) Value() ContainerGroup { 323 if !iter.page.NotDone() { 324 return ContainerGroup{} 325 } 326 return iter.page.Values()[iter.i] 327} 328 329// IsEmpty returns true if the ListResult contains no values. 330func (cglr ContainerGroupListResult) IsEmpty() bool { 331 return cglr.Value == nil || len(*cglr.Value) == 0 332} 333 334// containerGroupListResultPreparer prepares a request to retrieve the next set of results. 335// It returns nil if no more results exist. 336func (cglr ContainerGroupListResult) containerGroupListResultPreparer() (*http.Request, error) { 337 if cglr.NextLink == nil || len(to.String(cglr.NextLink)) < 1 { 338 return nil, nil 339 } 340 return autorest.Prepare(&http.Request{}, 341 autorest.AsJSON(), 342 autorest.AsGet(), 343 autorest.WithBaseURL(to.String(cglr.NextLink))) 344} 345 346// ContainerGroupListResultPage contains a page of ContainerGroup values. 347type ContainerGroupListResultPage struct { 348 fn func(ContainerGroupListResult) (ContainerGroupListResult, error) 349 cglr ContainerGroupListResult 350} 351 352// Next advances to the next page of values. If there was an error making 353// the request the page does not advance and the error is returned. 354func (page *ContainerGroupListResultPage) Next() error { 355 next, err := page.fn(page.cglr) 356 if err != nil { 357 return err 358 } 359 page.cglr = next 360 return nil 361} 362 363// NotDone returns true if the page enumeration should be started or is not yet complete. 364func (page ContainerGroupListResultPage) NotDone() bool { 365 return !page.cglr.IsEmpty() 366} 367 368// Response returns the raw server response from the last page request. 369func (page ContainerGroupListResultPage) Response() ContainerGroupListResult { 370 return page.cglr 371} 372 373// Values returns the slice of values for the current page or nil if there are no values. 374func (page ContainerGroupListResultPage) Values() []ContainerGroup { 375 if page.cglr.IsEmpty() { 376 return nil 377 } 378 return *page.cglr.Value 379} 380 381// ContainerGroupProperties ... 382type ContainerGroupProperties struct { 383 // ProvisioningState - The provisioning state of the container group. This only appears in the response. 384 ProvisioningState *string `json:"provisioningState,omitempty"` 385 // Containers - The containers within the container group. 386 Containers *[]Container `json:"containers,omitempty"` 387 // ImageRegistryCredentials - The image registry credentials by which the container group is created from. 388 ImageRegistryCredentials *[]ImageRegistryCredential `json:"imageRegistryCredentials,omitempty"` 389 // RestartPolicy - Restart policy for all containers within the container group. 390 // - `Always` Always restart 391 // - `OnFailure` Restart on failure 392 // - `Never` Never restart 393 // . Possible values include: 'Always', 'OnFailure', 'Never' 394 RestartPolicy ContainerGroupRestartPolicy `json:"restartPolicy,omitempty"` 395 // IPAddress - The IP address type of the container group. 396 IPAddress *IPAddress `json:"ipAddress,omitempty"` 397 // OsType - The operating system type required by the containers in the container group. Possible values include: 'Windows', 'Linux' 398 OsType OperatingSystemTypes `json:"osType,omitempty"` 399 // Volumes - The list of volumes that can be mounted by containers in this container group. 400 Volumes *[]Volume `json:"volumes,omitempty"` 401 // InstanceView - The instance view of the container group. Only valid in response. 402 InstanceView *ContainerGroupPropertiesInstanceView `json:"instanceView,omitempty"` 403} 404 405// ContainerGroupPropertiesInstanceView the instance view of the container group. Only valid in response. 406type ContainerGroupPropertiesInstanceView struct { 407 // Events - The events of this container group. 408 Events *[]Event `json:"events,omitempty"` 409 // State - The state of the container group. Only valid in response. 410 State *string `json:"state,omitempty"` 411} 412 413// ContainerPort the port exposed on the container instance. 414type ContainerPort struct { 415 // Protocol - The protocol associated with the port. Possible values include: 'ContainerNetworkProtocolTCP', 'ContainerNetworkProtocolUDP' 416 Protocol ContainerNetworkProtocol `json:"protocol,omitempty"` 417 // Port - The port number exposed within the container group. 418 Port *int32 `json:"port,omitempty"` 419} 420 421// ContainerProperties the container instance properties. 422type ContainerProperties struct { 423 // Image - The name of the image used to create the container instance. 424 Image *string `json:"image,omitempty"` 425 // Command - The commands to execute within the container instance in exec form. 426 Command *[]string `json:"command,omitempty"` 427 // Ports - The exposed ports on the container instance. 428 Ports *[]ContainerPort `json:"ports,omitempty"` 429 // EnvironmentVariables - The environment variables to set in the container instance. 430 EnvironmentVariables *[]EnvironmentVariable `json:"environmentVariables,omitempty"` 431 // InstanceView - The instance view of the container instance. Only valid in response. 432 InstanceView *ContainerPropertiesInstanceView `json:"instanceView,omitempty"` 433 // Resources - The resource requirements of the container instance. 434 Resources *ResourceRequirements `json:"resources,omitempty"` 435 // VolumeMounts - The volume mounts available to the container instance. 436 VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` 437} 438 439// ContainerPropertiesInstanceView the instance view of the container instance. Only valid in response. 440type ContainerPropertiesInstanceView struct { 441 // RestartCount - The number of times that the container instance has been restarted. 442 RestartCount *int32 `json:"restartCount,omitempty"` 443 // CurrentState - Current container instance state. 444 CurrentState *ContainerState `json:"currentState,omitempty"` 445 // PreviousState - Previous container instance state. 446 PreviousState *ContainerState `json:"previousState,omitempty"` 447 // Events - The events of the container instance. 448 Events *[]Event `json:"events,omitempty"` 449} 450 451// ContainerState the container instance state. 452type ContainerState struct { 453 // State - The state of the container instance. 454 State *string `json:"state,omitempty"` 455 // StartTime - The date-time when the container instance state started. 456 StartTime *date.Time `json:"startTime,omitempty"` 457 // ExitCode - The container instance exit codes correspond to those from the `docker run` command. 458 ExitCode *int32 `json:"exitCode,omitempty"` 459 // FinishTime - The date-time when the container instance state finished. 460 FinishTime *date.Time `json:"finishTime,omitempty"` 461 // DetailStatus - The human-readable status of the container instance state. 462 DetailStatus *string `json:"detailStatus,omitempty"` 463} 464 465// EnvironmentVariable the environment variable to set within the container instance. 466type EnvironmentVariable struct { 467 // Name - The name of the environment variable. 468 Name *string `json:"name,omitempty"` 469 // Value - The value of the environment variable. 470 Value *string `json:"value,omitempty"` 471} 472 473// Event a container group or container instance event. 474type Event struct { 475 // Count - The count of the event. 476 Count *int32 `json:"count,omitempty"` 477 // FirstTimestamp - The date-time of the earliest logged event. 478 FirstTimestamp *date.Time `json:"firstTimestamp,omitempty"` 479 // LastTimestamp - The date-time of the latest logged event. 480 LastTimestamp *date.Time `json:"lastTimestamp,omitempty"` 481 // Name - The event name. 482 Name *string `json:"name,omitempty"` 483 // Message - The event message. 484 Message *string `json:"message,omitempty"` 485 // Type - The event type. 486 Type *string `json:"type,omitempty"` 487} 488 489// ImageRegistryCredential image registry credential. 490type ImageRegistryCredential struct { 491 // Server - The Docker image registry server without a protocol such as "http" and "https". 492 Server *string `json:"server,omitempty"` 493 // Username - The username for the private registry. 494 Username *string `json:"username,omitempty"` 495 // Password - The password for the private registry. 496 Password *string `json:"password,omitempty"` 497} 498 499// IPAddress IP address for the container group. 500type IPAddress struct { 501 // Ports - The list of ports exposed on the container group. 502 Ports *[]Port `json:"ports,omitempty"` 503 // Type - Specifies if the IP is exposed to the public internet. 504 Type *string `json:"type,omitempty"` 505 // IP - The IP exposed to the public internet. 506 IP *string `json:"ip,omitempty"` 507} 508 509// Logs the logs. 510type Logs struct { 511 autorest.Response `json:"-"` 512 // Content - The content of the log. 513 Content *string `json:"content,omitempty"` 514} 515 516// Operation an operation for Azure Container Instance service. 517type Operation struct { 518 // Name - The name of the operation. 519 Name *string `json:"name,omitempty"` 520 // Display - The display information of the operation. 521 Display *OperationDisplay `json:"display,omitempty"` 522 // Origin - The intended executor of the operation. Possible values include: 'User', 'System' 523 Origin OperationsOrigin `json:"origin,omitempty"` 524} 525 526// OperationDisplay the display information of the operation. 527type OperationDisplay struct { 528 // Provider - The name of the provider of the operation. 529 Provider *string `json:"provider,omitempty"` 530 // Resource - The name of the resource type of the operation. 531 Resource *string `json:"resource,omitempty"` 532 // Operation - The friendly name of the operation. 533 Operation *string `json:"operation,omitempty"` 534 // Description - The description of the operation. 535 Description *string `json:"description,omitempty"` 536} 537 538// OperationListResult the operation list response that contains all operations for Azure Container Instance 539// service. 540type OperationListResult struct { 541 autorest.Response `json:"-"` 542 // Value - The list of operations. 543 Value *[]Operation `json:"value,omitempty"` 544} 545 546// Port the port exposed on the container group. 547type Port struct { 548 // Protocol - The protocol associated with the port. Possible values include: 'TCP', 'UDP' 549 Protocol ContainerGroupNetworkProtocol `json:"protocol,omitempty"` 550 // Port - The port number. 551 Port *int32 `json:"port,omitempty"` 552} 553 554// Resource the Resource model definition. 555type Resource struct { 556 // ID - The resource id. 557 ID *string `json:"id,omitempty"` 558 // Name - The resource name. 559 Name *string `json:"name,omitempty"` 560 // Type - The resource type. 561 Type *string `json:"type,omitempty"` 562 // Location - The resource location. 563 Location *string `json:"location,omitempty"` 564 // Tags - The resource tags. 565 Tags map[string]*string `json:"tags"` 566} 567 568// MarshalJSON is the custom marshaler for Resource. 569func (r Resource) MarshalJSON() ([]byte, error) { 570 objectMap := make(map[string]interface{}) 571 if r.ID != nil { 572 objectMap["id"] = r.ID 573 } 574 if r.Name != nil { 575 objectMap["name"] = r.Name 576 } 577 if r.Type != nil { 578 objectMap["type"] = r.Type 579 } 580 if r.Location != nil { 581 objectMap["location"] = r.Location 582 } 583 if r.Tags != nil { 584 objectMap["tags"] = r.Tags 585 } 586 return json.Marshal(objectMap) 587} 588 589// ResourceLimits the resource limits. 590type ResourceLimits struct { 591 // MemoryInGB - The memory limit in GB of this container instance. 592 MemoryInGB *float64 `json:"memoryInGB,omitempty"` 593 // CPU - The CPU limit of this container instance. 594 CPU *float64 `json:"cpu,omitempty"` 595} 596 597// ResourceRequests the resource requests. 598type ResourceRequests struct { 599 // MemoryInGB - The memory request in GB of this container instance. 600 MemoryInGB *float64 `json:"memoryInGB,omitempty"` 601 // CPU - The CPU request of this container instance. 602 CPU *float64 `json:"cpu,omitempty"` 603} 604 605// ResourceRequirements the resource requirements. 606type ResourceRequirements struct { 607 // Requests - The resource requests of this container instance. 608 Requests *ResourceRequests `json:"requests,omitempty"` 609 // Limits - The resource limits of this container instance. 610 Limits *ResourceLimits `json:"limits,omitempty"` 611} 612 613// Volume the properties of the volume. 614type Volume struct { 615 // Name - The name of the volume. 616 Name *string `json:"name,omitempty"` 617 // AzureFile - The name of the Azure File volume. 618 AzureFile *AzureFileVolume `json:"azureFile,omitempty"` 619 // EmptyDir - The empty directory volume. 620 EmptyDir interface{} `json:"emptyDir,omitempty"` 621} 622 623// VolumeMount the properties of the volume mount. 624type VolumeMount struct { 625 // Name - The name of the volume mount. 626 Name *string `json:"name,omitempty"` 627 // MountPath - The path within the container where the volume should be mounted. Must not contain colon (:). 628 MountPath *string `json:"mountPath,omitempty"` 629 // ReadOnly - The flag indicating whether the volume mount is read-only. 630 ReadOnly *bool `json:"readOnly,omitempty"` 631} 632