1// Copyright 2016-2020 The Libsacloud Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package sacloud
16
17import "time"
18
19// Instance インスタンス
20type Instance struct {
21	*EServerInstanceStatus            // ステータス
22	Server                 Resource   `json:",omitempty"` // サーバー
23	StatusChangedAt        *time.Time `json:",omitempty"` // ステータス変更日時
24	MigrationProgress      string     `json:",omitempty"` // コピージョブ進捗状態
25	MigrationSchedule      string     `json:",omitempty"` // コピージョブスケジュール
26	IsMigrating            bool       `json:",omitempty"` // コピージョブ実施中フラグ
27	MigrationAllowed       string     `json:",omitempty"` // コピージョブ許可
28	ModifiedAt             *time.Time `json:",omitempty"` // 変更日時
29	CDROM                  *CDROM     `json:",omitempty"` // ISOイメージ
30	CDROMStorage           *Storage   `json:",omitempty"` // ISOイメージストレージ
31
32	Host struct { // Host
33		Name          string `json:",omitempty"` // ホスト名
34		InfoURL       string `json:",omitempty"` // インフォURL
35		Class         string `json:",omitempty"` // クラス
36		Version       int    `json:",omitempty"` // バージョン
37		SystemVersion string `json:",omitempty"` // システムバージョン
38	} `json:",omitempty"`
39}
40
41// HasInfoURL Host.InfoURLに値があるか
42func (i *Instance) HasInfoURL() bool {
43	return i != nil && i.Host.InfoURL != ""
44}
45
46// MaintenanceScheduled メンテナンス予定の有無
47func (i *Instance) MaintenanceScheduled() bool {
48	return i.HasInfoURL()
49}
50