Passed
Pull Request — master (#19)
by eval
01:57
created

ssm/type.go   B

Size/Duplication

Total Lines 241
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 47
eloc 163
dl 0
loc 241
rs 8.64
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
C ssm.newParameterHistory 0 39 11
A ssm.newParameterInlinePolicyList 0 10 3
C ssm.newParameterMetadata 0 32 9
C ssm.newParameter 0 32 10
A ssm.newParameterHistoryList 0 10 3
A ssm.ParameterStringFilter.ToSDK 0 10 3
A ssm.newParameterInlinePolicy 0 16 5
A ssm.Tag.ToSDK 0 10 3
1
package ssm
2
3
import (
4
	"time"
5
6
	SDK "github.com/aws/aws-sdk-go-v2/service/ssm"
7
	"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers"
8
)
9
10
type Parameter struct {
0 ignored issues
show
introduced by
exported type Parameter should have comment or be unexported
Loading history...
11
	ARN              string
12
	DataType         string
13
	LastModifiedDate time.Time
14
	Name             string
15
	Selector         string
16
	SourceResult     string
17
	Type             ParameterType
18
	Value            string
19
	Version          int64
20
}
21
22
func newParameter(o *SDK.Parameter) Parameter {
23
	result := Parameter{}
24
	if o == nil {
25
		return result
26
	}
27
28
	if o.ARN != nil {
29
		result.ARN = *o.ARN
30
	}
31
	if o.DataType != nil {
32
		result.DataType = *o.DataType
33
	}
34
	if o.LastModifiedDate != nil {
35
		result.LastModifiedDate = *o.LastModifiedDate
36
	}
37
	if o.Name != nil {
38
		result.Name = *o.Name
39
	}
40
	if o.Selector != nil {
41
		result.Selector = *o.Selector
42
	}
43
	if o.SourceResult != nil {
44
		result.SourceResult = *o.SourceResult
45
	}
46
	result.Type = ParameterType(o.Type)
47
	if o.Value != nil {
48
		result.Value = *o.Value
49
	}
50
	if o.Version != nil {
51
		result.Version = *o.Version
52
	}
53
	return result
54
}
55
56
type ParameterHistory struct {
0 ignored issues
show
introduced by
exported type ParameterHistory should have comment or be unexported
Loading history...
57
	AllowedPattern   string
58
	DataType         string
59
	Description      string
60
	KeyID            string
61
	Labels           []string
62
	LastModifiedDate time.Time
63
	LastModifiedUser string
64
	Name             string
65
	Policies         []ParameterInlinePolicy
66
	Tier             ParameterTier
67
	Type             ParameterType
68
	Value            string
69
	Version          int64
70
}
71
72
func newParameterHistoryList(list []*SDK.ParameterHistory) []ParameterHistory {
73
	if len(list) == 0 {
74
		return nil
75
	}
76
77
	results := make([]ParameterHistory, len(list))
78
	for i, v := range list {
79
		results[i] = newParameterHistory(v)
80
	}
81
	return results
82
}
83
84
func newParameterHistory(o *SDK.ParameterHistory) ParameterHistory {
85
	result := ParameterHistory{}
86
	if o == nil {
87
		return result
88
	}
89
90
	if o.AllowedPattern != nil {
91
		result.AllowedPattern = *o.AllowedPattern
92
	}
93
	if o.DataType != nil {
94
		result.DataType = *o.DataType
95
	}
96
	if o.Description != nil {
97
		result.Description = *o.Description
98
	}
99
	if o.KeyId != nil {
100
		result.KeyID = *o.KeyId
101
	}
102
	if o.LastModifiedDate != nil {
103
		result.LastModifiedDate = *o.LastModifiedDate
104
	}
105
	if o.LastModifiedUser != nil {
106
		result.LastModifiedUser = *o.LastModifiedUser
107
	}
108
	if o.Name != nil {
109
		result.Name = *o.Name
110
	}
111
	if o.Value != nil {
112
		result.Value = *o.Value
113
	}
114
	if o.Version != nil {
115
		result.Version = *o.Version
116
	}
117
118
	result.Labels = o.Labels
119
	result.Policies = newParameterInlinePolicyList(o.Policies)
120
	result.Tier = ParameterTier(o.Tier)
121
	result.Type = ParameterType(o.Type)
122
	return result
123
}
124
125
type ParameterInlinePolicy struct {
0 ignored issues
show
introduced by
exported type ParameterInlinePolicy should have comment or be unexported
Loading history...
126
	PolicyStatus string
127
	PolicyText   string
128
	PolicyType   string
129
}
130
131
func newParameterInlinePolicyList(list []SDK.ParameterInlinePolicy) []ParameterInlinePolicy {
132
	if len(list) == 0 {
133
		return nil
134
	}
135
136
	results := make([]ParameterInlinePolicy, len(list))
137
	for i := range list {
138
		results[i] = newParameterInlinePolicy(&list[i])
139
	}
140
	return results
141
}
142
143
func newParameterInlinePolicy(o *SDK.ParameterInlinePolicy) ParameterInlinePolicy {
144
	result := ParameterInlinePolicy{}
145
	if o == nil {
146
		return result
147
	}
148
149
	if o.PolicyStatus != nil {
150
		result.PolicyStatus = *o.PolicyStatus
151
	}
152
	if o.PolicyText != nil {
153
		result.PolicyText = *o.PolicyText
154
	}
155
	if o.PolicyType != nil {
156
		result.PolicyType = *o.PolicyType
157
	}
158
	return result
159
}
160
161
type ParameterMetadata struct {
0 ignored issues
show
introduced by
exported type ParameterMetadata should have comment or be unexported
Loading history...
162
	AllowedPattern   string
163
	DataType         string
164
	Description      string
165
	KeyID            string
166
	LastModifiedDate time.Time
167
	LastModifiedUser string
168
	Name             string
169
	Policies         []ParameterInlinePolicy
170
	Tier             ParameterTier
171
	Type             ParameterType
172
	Version          int64
173
}
174
175
func newParameterMetadata(o SDK.ParameterMetadata) ParameterMetadata {
176
	result := ParameterMetadata{}
177
178
	if o.AllowedPattern != nil {
179
		result.AllowedPattern = *o.AllowedPattern
180
	}
181
	if o.DataType != nil {
182
		result.DataType = *o.DataType
183
	}
184
	if o.Description != nil {
185
		result.Description = *o.Description
186
	}
187
	if o.KeyId != nil {
188
		result.KeyID = *o.KeyId
189
	}
190
	if o.LastModifiedDate != nil {
191
		result.LastModifiedDate = *o.LastModifiedDate
192
	}
193
	if o.LastModifiedUser != nil {
194
		result.LastModifiedUser = *o.LastModifiedUser
195
	}
196
	if o.Name != nil {
197
		result.Name = *o.Name
198
	}
199
	if o.Version != nil {
200
		result.Version = *o.Version
201
	}
202
203
	result.Policies = newParameterInlinePolicyList(o.Policies)
204
	result.Tier = ParameterTier(o.Tier)
205
	result.Type = ParameterType(o.Type)
206
	return result
207
}
208
209
type ParameterStringFilter struct {
0 ignored issues
show
introduced by
exported type ParameterStringFilter should have comment or be unexported
Loading history...
210
	Key    string
211
	Option string
212
	Values []string
213
}
214
215
func (v ParameterStringFilter) ToSDK() SDK.ParameterStringFilter {
0 ignored issues
show
introduced by
exported method ParameterStringFilter.ToSDK should have comment or be unexported
Loading history...
216
	o := SDK.ParameterStringFilter{}
217
	if v.Key != "" {
218
		o.Key = pointers.String(v.Key)
219
	}
220
	if v.Option != "" {
221
		o.Option = pointers.String(v.Option)
222
	}
223
	o.Values = v.Values
224
	return o
225
}
226
227
type Tag struct {
0 ignored issues
show
introduced by
exported type Tag should have comment or be unexported
Loading history...
228
	Key   string
229
	Value string
230
}
231
232
func (r Tag) ToSDK() SDK.Tag {
0 ignored issues
show
introduced by
exported method Tag.ToSDK should have comment or be unexported
Loading history...
233
	o := SDK.Tag{}
234
235
	if r.Key != "" {
236
		o.Key = pointers.String(r.Key)
237
	}
238
	if r.Value != "" {
239
		o.Value = pointers.String(r.Value)
240
	}
241
	return o
242
}
243