This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
743 lines (654 loc) · 21.2 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
package certcenter
import (
"fmt"
"net/http"
"time"
)
// Bearer represents the authentication token you're going to use
var Bearer string
// KvStoreAuthorizationKey need to be set if you want to use
// CertCenter's free key-value database, please ask your partner
// manager or our customer support team to send you an
// "AlwaysOnSSL KV-Storage Authorization-Key"
var KvStoreAuthorizationKey string
const (
// CC_PARAM_TYPE_QS is QueryString (eg. ?CertCenterOrderId=123)
CC_PARAM_TYPE_QS = 1 << iota
// CC_PARAM_TYPE_PATH is Path (eg. /:CertCenterOrderId/)
CC_PARAM_TYPE_PATH
// CC_PARAM_TYPE_BODY is Body (JSON POST)
CC_PARAM_TYPE_BODY
)
func checkErr(err error) {
if err != nil {
fmt.Println(err)
}
}
// Represents an API request
type apiRequest struct {
method string
httpMethod string
url string
result interface{}
request interface{}
client *http.Client
statusCode int
}
// SchemeValidationErrors provides basic fields for scheme validation errors
type SchemeValidationErrors struct {
Errors []struct {
Msg string `json:"msg"`
Status string `json:"status"`
Key string `json:"key"`
SchemeValidationErrors
}
}
// BasicResultInfo represents the default values included in each resultset
type BasicResultInfo struct {
Success bool `json:"success"`
Message string
// if !Success, ErrorId and/or ErrorField may be provided
ErrorId int
ErrorField string
// Scheme validation results
Msg string `json:"msg"`
SchemeValidationErrors
}
// ProfileResult represents a GET /Profile response
type ProfileResult struct {
AuthType string
AuthorizationID int64
Country string
Currency string
CustomerID int64
Locale string
OAuth2Token string `json:"OAuth2_Token"`
Scope string
Timezone string
}
// LimitResult represents a GET /Limit response
type LimitResult struct {
BasicResultInfo
LimitInfo struct {
Limit float64
Used float64
}
}
// ProductsResult represents a GET /Products response
type ProductsResult struct {
BasicResultInfo
Products []string
}
// ProductDetailsResult represents a GET /ProductDetails response
type ProductDetailsResult struct {
BasicResultInfo
ProductDetails struct {
CA string
Currency string
Features []string
Licenses int
MaxValidityPeriod int
Price float64
ProductCode string
ProductName string
RefundPeriod int
RenewPeriod int
SANFeatures []string
SANHostPrice float64
SANMaxHosts int
SANPackagePrice float64
SANPackageSize int
}
}
// ProductDetailsRequest represents a GET /ProductDetails request
type ProductDetailsRequest struct {
ProductCode string
}
// QuoteResult represents a GET /Quote response
type QuoteResult struct {
BasicResultInfo
Currency string
OrderParameters struct {
ProductCode string
ServerCount int
SubjectAltNameCount int
ValidityPeriod int
}
Price float64
}
// QuoteRequest represents a GET /Quote request
type QuoteRequest struct {
ProductCode string
SubjectAltNameCount int
ValidityPeriod int
ServerCount int
}
// ValidateCSRResult represents a POST /ValidateCSR response
type ValidateCSRResult struct {
BasicResultInfo
ParsedCSR struct {
CommonName string
Organization string
OrganizationUnit string
Email string
State string
Locality string
Country string
KeyLength int
SignaturAlgorithm string
KeyEncryptionAlgorithm string
HashMD5 string
HashSHA256 string
UniqueValue string
}
}
// ValidateCSRRequest represents a POST /ValidateCSR request
type ValidateCSRRequest struct {
CSR string // PEM-encoded PKCS#10
}
// UserAgreementRequest represents a GET /ProductDetails response
type UserAgreementRequest struct {
ProductCode string
}
// UserAgreementResult represents a GET /ProductDetails request
type UserAgreementResult struct {
BasicResultInfo
ProductCode string
UserAgreement string
}
// ApproverListResult represents a GET /ApproverList request
type ApproverListRequest struct {
CommonName string
ProductCode string `json:",omitempty"`
DNSNames string `json:",omitempty"`
}
// ApproverListRequest represents a GET /ApproverList response
type ApproverListResult struct {
BasicResultInfo
// New approver information structure to
// better implement BR 3.2.2.4 requirements
DomainApprovers *DomainApprovers `json:",omitempty"`
// Keep this legacy structure for backward compatibility reasons
ApproverList []Approver `json:",omitempty"`
}
// DomainApprovers contains the DomainApprover structure
type DomainApprovers struct {
DomainApprover []DomainApproverItem `json:",omitempty"`
}
type DomainApproverItem struct {
Domain string `json:",omitempty"`
Approvers []Approver `json:",omitempty"`
}
// DomainApprover contains pairs of valid approver information
type Approver struct {
ApproverEmail string
ApproverType string `json:",omitempty"` // Domain or Generic
}
// OrderResult represents a POST /Order response
type OrderResult struct {
BasicResultInfo
Timestamp time.Time
CertCenterOrderID int64
OrderParameters struct {
CSR string // PEM-encoded PKCS#10
IsCompetitiveUpgrade bool
IsRenewal bool
PartnerOrderID string
ProductCode string
ServerCount int
SignatureHashAlgorithm string
SubjectAltNameCount int
SubjectAltNames []string
ValidityPeriod int // 12 or 24 month (days for AlwaysOnSSL, min. 180, max. 365)
DVAuthMethod string // DNS, EMAIL, FILE
}
// AlwaysOnSSL (Encryption Everywhere) only:
Fulfillment struct {
Certificate string
PKCS7 string `json:"Certificate_PKCS7"`
Intermediate string
}
}
// OrderParameters represents generic Order Parameters
type OrderParameters struct {
CSR string `json:",omitempty"` // PEM-encoded PKCS#10
IsCompetitiveUpgrade bool `json:",omitempty"`
IsRenewal bool `json:",omitempty"`
PartnerOrderID string `json:",omitempty"`
ProductCode string `json:",omitempty"`
ServerCount int `json:",omitempty"`
SignatureHashAlgorithm string `json:",omitempty"`
SubjectAltNameCount int `json:",omitempty"`
SubjectAltNames []string `json:",omitempty"`
ValidityPeriod int `json:",omitempty"` // 12 or 24 month (days for AlwaysOnSSL, min. 180, max. 365)
DVAuthMethod string `json:",omitempty"` // DNS, EMAIL, FILE
DomainApprovers *DomainApprovers `json:",omitempty"` // Domain Control Validation
ApproverEmail string `json:",omitempty"` // deprecated
}
// OrganizationInfo represents organizational information
type OrganizationInfo struct {
OrganizationName string `json:",omitempty"`
OrganizationAddress *OrganizationAddress `json:",omitempty"`
}
// OrganizationAddress holds general information about a organization
type OrganizationAddress struct {
AddressLine1 string `json:",omitempty"`
PostalCode string `json:",omitempty"`
City string `json:",omitempty"`
Region string `json:",omitempty"`
Country string `json:",omitempty"`
Phone string `json:",omitempty"`
Fax string `json:",omitempty"`
}
// Contact represents a generic Contact type (for AdminContact and TechContact)
type Contact struct {
Title string `json:",omitempty"`
FirstName string `json:",omitempty"`
LastName string `json:",omitempty"`
OrganizationName string `json:",omitempty"`
OrganizationAddress *OrganizationAddress `json:",omitempty"`
Phone string `json:",omitempty"`
Fax string `json:",omitempty"`
Email string `json:",omitempty"`
}
// OrderRequest represents a POST /Order request
type OrderRequest struct {
OrganizationInfo *OrganizationInfo `json:",omitempty"`
OrderParameters *OrderParameters `json:",omitempty"`
AdminContact *Contact `json:",omitempty"`
TechContact *Contact `json:",omitempty"`
}
// PutApproverEmailResult represents a PUT /ApproverEmail response
type PutApproverEmailResult struct {
BasicResultInfo
}
// PutApproverEmailRequest represents a PUT /ApproverEmail request
type PutApproverEmailRequest struct {
CertCenterOrderID int64
ApproverEmail string
}
// ResendApproverEmailResult represents a POST /ApproverEmail response
type ResendApproverEmailResult struct {
BasicResultInfo
}
// ResendApproverEmailRequest represents a POST /ApproverEmail request
type ResendApproverEmailRequest struct {
CertCenterOrderID int64
}
type OrderStatus struct {
MajorStatus string
MinorStatus string
OrderDate time.Time
UpdateDate time.Time
StartDate time.Time
EndDate time.Time
Progress int
}
type ConfigurationAssessment struct { // done by ssllabs.com
Engine string
Ranking string
Effective time.Time
CriteriaVersion string
}
type BillingInfo struct {
Price float32
Currency string
Status string
InvoiceRef string // if available (Status == cleared)
}
type ContactInfoPair struct {
AdminContact Contact
TechContact Contact
}
type Fulfillment struct {
StartDate time.Time
EndDate time.Time
CSR string
Certificate string
Intermediate string
DownloadLinks struct { // cert.sh download links
Certificate string
Intermediate string
IconScript string
PKCS7 string
}
}
type DNSAuthDetails struct { // for DV orders with DNS auth and includeOrderParameters [deprecated]
DNSEntry string
DNSValue string
Example string
FQDNs []string
}
type FileAuthDetails struct { // for DV orders with FILE auth and includeOrderParameters [deprecated]
FileContents string
FileName string
FilePath string
PollStatus string
LastPollDate time.Time
FQDNs []string
}
type EmailAuthDetails struct { // for DV orders with EMAIL auth and includeOrderParameters [deprecated]
ApproverEmail string
ApproverNotifyDate time.Time
ApproverConfirmDate time.Time
}
// OrderInfo contains all information about a certain order
type OrderInfo struct {
CertCenterOrderID int64
CommonName string
OrderStatus OrderStatus
ConfigurationAssessment ConfigurationAssessment
BillingInfo BillingInfo
OrderParameters OrderParameters
ContactInfo ContactInfoPair
OrganizationInfo OrganizationInfo
Fulfillment Fulfillment
DNSAuthDetails DNSAuthDetails
FileAuthDetails FileAuthDetails
EmailAuthDetails EmailAuthDetails
DCVStatus []DCVStatus
}
type DCVStatus struct {
DomainControlValidationID int32
Domain string
Status string
ApproverEmail string
LastCheckDate time.Time
LastUpdateDate time.Time
}
// GetOrdersResult represents a GET /Orders response
type GetOrdersResult struct {
BasicResultInfo
OrderInfos []OrderInfo
Meta struct {
ItemsAvailable int64
ItemsPerPage int64
Page int64
OrderBy string
OrderDir string
Status []string
ProductType []string
CommonName string
} `json:"_meta"`
}
// GetOrdersRequest represents a GET /Orders request
type GetOrdersRequest struct {
Status string
ProductType string
CommonName string
IncludeFulfillment bool `url:"includeFulfillment"`
IncludeOrderParameters bool `url:"includeOrderParameters"`
IncludeBillingDetails bool `url:"includeBillingDetails"`
IncludeContacts bool `url:"includeContacts"`
IncludeOrganizationInfos bool `url:"includeOrganizationInfos"`
IncludeDCVStatus bool `url:"includeDCVStatus"`
}
// GetModifiedOrdersResult represents a GET /ModifiedOrders response
type GetModifiedOrdersResult struct {
OrderInfos []OrderInfo
BasicResultInfo
}
// GetModifiedOrdersRequest represents a GET /ModifiedOrders request
type GetModifiedOrdersRequest struct {
FromDate time.Time
ToDate time.Time
IncludeFulfillment bool `url:"includeFulfillment"`
IncludeOrderParameters bool `url:"includeOrderParameters"`
IncludeBillingDetails bool `url:"includeBillingDetails"`
IncludeContacts bool `url:"includeContacts"`
IncludeOrganizationInfos bool `url:"includeOrganizationInfos"`
IncludeDCVStatus bool `url:"includeDCVStatus"`
}
// GetOrderResult represents a GET /Order/:CertCenterOrderID response
type GetOrderResult struct {
BasicResultInfo
OrderInfo OrderInfo
}
// GetOrderRequest represents a GET /Order/:CertCenterOrderID request
type GetOrderRequest struct {
CertCenterOrderID int64
IncludeFulfillment bool `url:"includeFulfillment"`
IncludeOrderParameters bool `url:"includeOrderParameters"`
IncludeBillingDetails bool `url:"includeBillingDetails"`
IncludeContacts bool `url:"includeContacts"`
IncludeOrganizationInfos bool `url:"includeOrganizationInfos"`
IncludeDCVStatus bool `url:"includeDCVStatus"`
}
// DeleteOrderResult represents a DELETE /Order/:CertCenterOrderID response
type DeleteOrderResult struct {
BasicResultInfo
}
// DeleteOrderRequest represents a DELETE /Order/:CertCenterOrderID request
type DeleteOrderRequest struct {
CertCenterOrderID int64
}
// ReissueResult represents a POST /Reissue response
type ReissueResult struct {
BasicResultInfo
}
// ReissueOrderParameters represents the required OrderParameters for POST /Reissue
type ReissueOrderParameters struct {
CSR string
DVAuthMethod string
SignatureHashAlgorithm string
DomainApprovers *DomainApprovers `json:",omitempty"` // Domain Control Validation
}
// ReissueRequest represents a POST /Reissue request
// Description:
// https://developers.certcenter.com/reference#reissue
type ReissueRequest struct {
CertCenterOrderID int64
OrderParameters ReissueOrderParameters
ReissueEmail string
}
// RevokeResult represents a DELETE /Revoke response
type RevokeResult struct {
BasicResultInfo
}
// RevokeRequest represents a DELETE /Revoke request
type RevokeRequest struct {
CertCenterOrderID int64
// optional parameters
RevokeReason string `json:",omitempty"`
Certificate string `json:",omitempty"` // PEM encoded X.509 certificate
}
type BaseDomainRequest struct {
FQDN string `json:"fqdn"`
}
type BaseDomainResult struct {
FQDN string `json:"fqdn"`
Domain string `json:"domain"`
}
// ValidateNameResult represents a POST /ValidateName response
type ValidateNameResult struct {
BasicResultInfo
IsQualified bool
// If ValidateNameRequest contained a GeneratePrivateKey=true
// this two values are included in the result:
CSR string
PrivateKey string
}
// ValidateNameRequest represents a POST /ValidateName request
// https://developers.certcenter.com/v1/reference#validatename
type ValidateNameRequest struct {
CommonName string
GeneratePrivateKey bool // Generates a private key for you.
// If true the response will also include the CSR and PrivateKey values.
}
// DNSDataResult represents a POST /DNSData response
type DNSDataResult struct {
BasicResultInfo
DNSAuthDetails struct {
PointerType string // =CNAME
DNSEntry string
DNSValue string
Example string
}
}
// DNSDataRequest represents a POST /DNSData request
// https://developers.certcenter.com/v1/reference#dnsdata
type DNSDataRequest struct {
ProductCode string
CSR string
}
// FileDataResult represents a POST /FileData response
type FileDataResult struct {
BasicResultInfo
FileAuthDetails struct {
FileContents string
FileName string
FilePath string
}
}
// FileDataRequest represents a POST /FileData request
// https://developers.certcenter.com/v1/reference#filedata
type FileDataRequest struct {
ProductCode string
CSR string
}
// VulnerabilityAssessmentResult represents a POST /VulnerabilityAssessment response
type VulnerabilityAssessmentResult struct {
BasicResultInfo
}
// VulnerabilityAssessmentRequest represents a POST /VulnerabilityAssessment request
// https://developers.certcenter.com/v1/reference#vulnerabilityassessment
type VulnerabilityAssessmentRequest struct {
CertCenterOrderID int64
ServiceStatus string
EmailNotificationLevel string
}
// VulnerabilityAssessmentRescanResult represents a GET /VulnerabilityAssessment/:CertCenterOrderID response
type VulnerabilityAssessmentRescanResult struct {
BasicResultInfo
}
// VulnerabilityAssessmentRescanRequest represents a GET /VulnerabilityAssessmen/:CertCenterOrderID request
// https://developers.certcenter.com/v1/reference#vulnerabilityassessmentrescan
type VulnerabilityAssessmentRescanRequest struct {
CertCenterOrderID int64
}
// UserData represents a basic field-set for /User transactions
type UserData struct {
UsernameOrUserId string `json:",omitempty"`
FullName string `json:",omitempty"`
Email string `json:",omitempty"`
Username string `json:",omitempty"`
Password string `json:",omitempty"`
Roles []string `json:",omitempty"`
Mobile string `json:",omitempty"`
Timezone string `json:",omitempty"`
Locale string `json:",omitempty"`
// Available on user data retrieval
SpecialProductAvailability bool `json:",omitempty"`
Scope string `json:",omitempty"`
Active bool `json:",omitempty"`
TwoFactorEnabled bool `json:",omitempty"`
InsertDate int64 `json:",omitempty"` // Unix time
LastUpdateDate int64 `json:",omitempty"` // Unix time
LastPasswordChangeDate int64 `json:",omitempty"` // Unix time
}
// CreateUserResult represents a POST /User response
type CreateUserResult struct {
BasicResultInfo
Id int64
FullName string
Username string
Roles []string
}
// CreateUserRequest represents a POST /User request
// https://developers.certcenter.com/v1/reference#createuser
type CreateUserRequest struct {
UserData
}
// UpdateUserResult represents a POST /User/:UsernameOrUserId response
type UpdateUserResult struct {
BasicResultInfo
Id int64
}
// UpdateUserRequest represents a POST /User/:UsernameOrUserId request
// https://developers.certcenter.com/v1/reference#updateuser
type UpdateUserRequest struct {
UserData
}
// GetUserResult represents a GET /User/:UsernameOrUserId response
type GetUserResult struct {
BasicResultInfo
Id int64
}
// GetUserRequest represents a GET /User/:UsernameOrUserId request
// https://developers.certcenter.com/v1/reference#getuser
type GetUserRequest struct {
UserData
}
// DeleteUserResult represents a DELETE /User/:UsernameOrUserId response
type DeleteUserResult struct {
BasicResultInfo
Id int64
}
// DeleteUserRequest represents a GET /User/:UsernameOrUserId request
// https://developers.certcenter.com/v1/reference#deleteuser
type DeleteUserRequest struct {
UsernameOrUserId string
}
// KeyValueStoreResult represents a basic kv-storage response
type KeyValueStoreResult struct {
Message string `json:"message"`
}
// KeyValueStoreRequest represents a basic kv-storage request
type KeyValueStoreRequest struct {
Key string `json:"filename,omitempty"`
Value string `json:"hash"`
}
// CreateVoucherResult represents a POST /Voucher response
type CreateVoucherResult struct {
BasicResultInfo
VoucherCode string
OrderParameters OrderParameters
}
// CreateVoucherRequest represents a POST /Voucher request
// https://developers.certcenter.com/v1/reference#createvoucher
type CreateVoucherRequest struct {
OrderParameters OrderParameters
}
// RedeemVoucherResult represents a POST /Redeem response
type RedeemVoucherResult struct {
OrderResult
}
// RedeemVoucherRequest represents a POST /Redeem request
// https://developers.certcenter.com/v1/reference#redeemvoucher
type RedeemVoucherRequest struct {
VoucherCode string
OrganizationInfo *OrganizationInfo `json:",omitempty"`
OrderParameters *OrderParameters `json:",omitempty"`
AdminContact *Contact `json:",omitempty"`
TechContact *Contact `json:",omitempty"`
}
// GetVouchersResult represents a GET /Vouchers and a GET /Voucher/:VoucherCode response
// https://developers.certcenter.com/v1/reference#getvouchers
// https://developers.certcenter.com/v1/reference#getvoucher
type GetVouchersResult struct {
BasicResultInfo
Vouchers []struct {
RedeemInfo struct {
RedeemDate time.Time
CertCenterOrderID int64
}
CreationDate time.Time
OrderParameters OrderParameters
VoucherCode string
Redeemed bool
}
}
// GetVoucherRequest represents a GET /Voucher/:VoucherCode request
// https://developers.certcenter.com/v1/reference#getvoucher
type GetVoucherRequest struct {
VoucherCode string
}
// DeleteVoucherResult represents a DELETE /Voucher/:VoucherCode response
type DeleteVoucherResult struct {
OrderResult
}
// DeleteVoucherRequest represents a DELETE /Voucher/:VoucherCode request
// https://developers.certcenter.com/v1/reference#deletevoucher
type DeleteVoucherRequest struct {
VoucherCode string
}