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// propCopySource コピー元情報内包型
18type propCopySource struct {
19	SourceDisk    *Disk    `json:",omitempty"` // コピー元ディスク
20	SourceArchive *Archive `json:",omitempty"` // コピー元アーカイブ
21
22}
23
24// SetSourceArchive ソースアーカイブ設定
25func (p *propCopySource) SetSourceArchive(sourceID ID) {
26	if sourceID.IsEmpty() {
27		return
28	}
29	p.SourceArchive = &Archive{
30		Resource: &Resource{ID: sourceID},
31	}
32	p.SourceDisk = nil
33}
34
35// SetSourceDisk ソースディスク設定
36func (p *propCopySource) SetSourceDisk(sourceID ID) {
37	if sourceID.IsEmpty() {
38		return
39	}
40	p.SourceDisk = &Disk{
41		Resource: &Resource{ID: sourceID},
42	}
43	p.SourceArchive = nil
44}
45
46// GetSourceArchive ソースアーカイブ取得
47func (p *propCopySource) GetSourceArchive() *Archive {
48	return p.SourceArchive
49}
50
51// GetSourceDisk ソースディスク取得
52func (p *propCopySource) GetSourceDisk() *Disk {
53	return p.SourceDisk
54}
55
56// GetSourceArchiveID ソースアーカイブID取得
57func (p *propCopySource) GetSourceArchiveID() ID {
58	if p.SourceArchive != nil {
59		return p.SourceArchive.ID
60	}
61	return EmptyID
62}
63
64// GetSourceDiskID ソースディスクID取得
65func (p *propCopySource) GetSourceDiskID() ID {
66	if p.SourceDisk != nil {
67		return p.SourceDisk.ID
68	}
69	return EmptyID
70}
71