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
17// propSizeMB サイズ(MB)内包型
18type propSizeMB struct {
19	SizeMB int `json:",omitempty"` // サイズ(MB単位)
20}
21
22// GetSizeMB サイズ(MB単位) 取得
23func (p *propSizeMB) GetSizeMB() int {
24	return p.SizeMB
25}
26
27// SetSizeMB サイズ(MB単位) 設定
28func (p *propSizeMB) SetSizeMB(size int) {
29	p.SizeMB = size
30}
31
32// GetSizeGB サイズ(GB単位) 取得
33func (p *propSizeMB) GetSizeGB() int {
34	if p.SizeMB <= 0 {
35		return 0
36	}
37	return p.SizeMB / 1024
38}
39
40// SetSizeGB サイズ(GB単位) 設定
41func (p *propSizeMB) SetSizeGB(size int) {
42	if size <= 0 {
43		p.SizeMB = 0
44	} else {
45		p.SizeMB = size * 1024
46	}
47}
48
49// propMigratedMB コピー済みデータサイズ(MB単位)内包型
50type propMigratedMB struct {
51	MigratedMB int `json:",omitempty"` // コピー済みデータサイズ(MB単位)
52}
53
54// GetMigratedMB サイズ(MB単位) 取得
55func (p *propMigratedMB) GetMigratedMB() int {
56	return p.MigratedMB
57}
58
59// SetMigratedMB サイズ(MB単位) 設定
60func (p *propMigratedMB) SetMigratedMB(size int) {
61	p.MigratedMB = size
62}
63
64// GetMigratedGB サイズ(GB単位) 取得
65func (p *propMigratedMB) GetMigratedGB() int {
66	if p.MigratedMB <= 0 {
67		return 0
68	}
69	return p.MigratedMB / 1024
70}
71
72// SetMigratedGB サイズ(GB単位) 設定
73func (p *propMigratedMB) SetMigratedGB(size int) {
74	if size <= 0 {
75		p.MigratedMB = 0
76	} else {
77		p.MigratedMB = size * 1024
78	}
79}
80