dns.go raw
1 // Copyright 2022-2025 The sacloud/iaas-api-go 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
15 package naked
16
17 import (
18 "encoding/json"
19 "time"
20
21 "github.com/sacloud/iaas-api-go/types"
22 )
23
24 // DNS DNSゾーン
25 type DNS struct {
26 ID types.ID `json:",omitempty" yaml:"id,omitempty" structs:",omitempty"`
27 Name string `json:",omitempty" yaml:"name,omitempty" structs:",omitempty"`
28 Description string `yaml:"description"`
29 Tags types.Tags `yaml:"tags"`
30 Icon *Icon `json:",omitempty" yaml:"icon,omitempty" structs:",omitempty"`
31 CreatedAt *time.Time `json:",omitempty" yaml:"created_at,omitempty" structs:",omitempty"`
32 ModifiedAt *time.Time `json:",omitempty" yaml:"modified_at,omitempty" structs:",omitempty"`
33 Availability types.EAvailability `json:",omitempty" yaml:"availability,omitempty" structs:",omitempty"`
34 ServiceClass string `json:",omitempty" yaml:"service_class,omitempty" structs:",omitempty"`
35 Provider *Provider `json:",omitempty" yaml:"provider,omitempty" structs:",omitempty"`
36 Settings *DNSSettings `json:",omitempty" yaml:"settings,omitempty" structs:",omitempty"`
37 SettingsHash string `json:",omitempty" yaml:"settings_hash,omitempty" structs:",omitempty"`
38 Status *DNSStatus `json:",omitempty" yaml:"status,omitempty" structs:",omitempty"`
39 }
40
41 // DNSSettingsUpdate DNSゾーン
42 type DNSSettingsUpdate struct {
43 Settings *DNSSettings `json:",omitempty" yaml:"settings,omitempty" structs:",omitempty"`
44 SettingsHash string `json:",omitempty" yaml:"settings_hash,omitempty" structs:",omitempty"`
45 }
46
47 // DNSStatus DNSステータス
48 type DNSStatus struct {
49 Zone string `json:",omitempty" yaml:"zone,omitempty" structs:",omitempty"`
50 NS []string `json:",omitempty" yaml:"ns,omitempty" structs:",omitempty"`
51 }
52
53 // DNSSettings DNSセッティング
54 type DNSSettings struct {
55 DNS *DNSSetting `json:",omitempty" yaml:"dns,omitempty" structs:",omitempty"`
56 }
57
58 // DNSSetting DNSセッティング
59 type DNSSetting struct {
60 ResourceRecordSets []*DNSRecord `yaml:"resource_record_sets"`
61 MonitoringSuiteLog *MonitoringSuiteLogString `json:",omitempty" yaml:"monitoring_suite_log,omitempty" structs:",omitempty"`
62 }
63
64 // MarshalJSON nullの場合に空配列を出力するための実装
65 func (ds DNSSetting) MarshalJSON() ([]byte, error) {
66 if ds.ResourceRecordSets == nil {
67 ds.ResourceRecordSets = make([]*DNSRecord, 0)
68 }
69 type alias DNSSetting
70 tmp := alias(ds)
71 return json.Marshal(&tmp)
72 }
73
74 // DNSRecord DNSレコード
75 type DNSRecord struct {
76 Name string `json:",omitempty" yaml:"name,omitempty" structs:",omitempty"` // ホスト名
77 Type types.EDNSRecordType `json:",omitempty" yaml:"type,omitempty" structs:",omitempty"` // レコードタイプ
78 RData string `json:",omitempty" yaml:"rdata,omitempty" structs:",omitempty"` // レコードデータ
79 TTL int `json:",omitempty" yaml:"ttl,omitempty" structs:",omitempty"` // TTL
80 }
81