From 484c0336a1eabe7c491917d19274e6fa90ee518a Mon Sep 17 00:00:00 2001 From: mittwald-machine Date: Wed, 29 Jan 2025 19:02:12 +0000 Subject: [PATCH] chore: update auto-generated code --- .../domain/updaterecordset_request_body.go | 18 +++++ .../updaterecordset_request_body_test.go | 8 ++ .../updaterecordset_request_path_recordset.go | 4 +- .../clients/user/authenticate_response.go | 30 ++++---- .../user/authenticate_response_test.go | 12 +-- .../clients/user/changepassword_response.go | 28 +++---- .../user/changepassword_response_test.go | 12 +-- .../generated/schemas/dnsv1/recordcaa.go | 73 +++++++++++++++++++ .../generated/schemas/dnsv1/recordcaa_test.go | 33 +++++++++ .../schemas/dnsv1/recordcaacomponent.go | 47 ++++++++++++ .../schemas/dnsv1/recordcaacomponent_test.go | 24 ++++++ .../schemas/dnsv1/recordcaarecord.go | 41 +++++++++++ .../schemas/dnsv1/recordcaarecord_tag.go | 26 +++++++ .../schemas/dnsv1/recordcaarecord_test.go | 24 ++++++ mittwaldv2/generated/schemas/dnsv1/zone.go | 2 + .../generated/schemas/dnsv1/zone_recordset.go | 6 ++ .../schemas/dnsv1/zone_recordset_test.go | 2 +- .../generated/schemas/dnsv1/zone_test.go | 2 +- 18 files changed, 348 insertions(+), 44 deletions(-) create mode 100644 mittwaldv2/generated/schemas/dnsv1/recordcaa.go create mode 100644 mittwaldv2/generated/schemas/dnsv1/recordcaa_test.go create mode 100644 mittwaldv2/generated/schemas/dnsv1/recordcaacomponent.go create mode 100644 mittwaldv2/generated/schemas/dnsv1/recordcaacomponent_test.go create mode 100644 mittwaldv2/generated/schemas/dnsv1/recordcaarecord.go create mode 100644 mittwaldv2/generated/schemas/dnsv1/recordcaarecord_tag.go create mode 100644 mittwaldv2/generated/schemas/dnsv1/recordcaarecord_test.go diff --git a/mittwaldv2/generated/clients/domain/updaterecordset_request_body.go b/mittwaldv2/generated/clients/domain/updaterecordset_request_body.go index 7e0ac79..01fb0b9 100644 --- a/mittwaldv2/generated/clients/domain/updaterecordset_request_body.go +++ b/mittwaldv2/generated/clients/domain/updaterecordset_request_body.go @@ -20,6 +20,7 @@ import ( // - {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordTXTComponent"} // - {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordSRVComponent"} // - {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCNAMEComponent"} +// - {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCAAComponent"} // description: UpdateRecordSetRequestBody models the JSON body of a 'dns-update-record-set' request type UpdateRecordSetRequestBody struct { @@ -29,6 +30,7 @@ type UpdateRecordSetRequestBody struct { AlternativeRecordTXTComponent *dnsv1.RecordTXTComponent AlternativeRecordSRVComponent *dnsv1.RecordSRVComponent AlternativeRecordCNAMEComponent *dnsv1.RecordCNAMEComponent + AlternativeRecordCAAComponent *dnsv1.RecordCAAComponent } func (a *UpdateRecordSetRequestBody) MarshalJSON() ([]byte, error) { @@ -50,6 +52,9 @@ func (a *UpdateRecordSetRequestBody) MarshalJSON() ([]byte, error) { if a.AlternativeRecordCNAMEComponent != nil { return json.Marshal(a.AlternativeRecordCNAMEComponent) } + if a.AlternativeRecordCAAComponent != nil { + return json.Marshal(a.AlternativeRecordCAAComponent) + } return []byte("null"), nil } @@ -119,6 +124,16 @@ func (a *UpdateRecordSetRequestBody) UnmarshalJSON(input []byte) error { } } + reader.Reset(input) + var alternativeRecordCAAComponent dnsv1.RecordCAAComponent + if err := dec.Decode(&alternativeRecordCAAComponent); err == nil { + //subtype: *generator.ReferenceType + if vErr := alternativeRecordCAAComponent.Validate(); vErr == nil { + a.AlternativeRecordCAAComponent = &alternativeRecordCAAComponent + decodedAtLeastOnce = true + } + } + if !decodedAtLeastOnce { return fmt.Errorf("could not unmarshal into any alternative for type %T", a) } @@ -144,5 +159,8 @@ func (a *UpdateRecordSetRequestBody) Validate() error { if a.AlternativeRecordCNAMEComponent != nil { return a.AlternativeRecordCNAMEComponent.Validate() } + if a.AlternativeRecordCAAComponent != nil { + return a.AlternativeRecordCAAComponent.Validate() + } return errors.New("no alternative set") } diff --git a/mittwaldv2/generated/clients/domain/updaterecordset_request_body_test.go b/mittwaldv2/generated/clients/domain/updaterecordset_request_body_test.go index 426a44c..3eecee1 100644 --- a/mittwaldv2/generated/clients/domain/updaterecordset_request_body_test.go +++ b/mittwaldv2/generated/clients/domain/updaterecordset_request_body_test.go @@ -61,5 +61,13 @@ var _ = Describe("UpdateRecordSetRequestBody", func() { Expect(sut.Validate()).To(Succeed()) Expect(sut.AlternativeRecordCNAMEComponent).NotTo(BeNil()) }) + It("should unmarshal into AlternativeRecordCAAComponent", func() { + exampleJSON := []byte("{\"records\":[{\"flags\":42,\"tag\":\"issue\",\"value\":\"string\"}],\"settings\":{\"ttl\":{\"seconds\":42}}}") + + sut := domain.UpdateRecordSetRequestBody{} + Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) + Expect(sut.Validate()).To(Succeed()) + Expect(sut.AlternativeRecordCAAComponent).NotTo(BeNil()) + }) }) }) diff --git a/mittwaldv2/generated/clients/domain/updaterecordset_request_path_recordset.go b/mittwaldv2/generated/clients/domain/updaterecordset_request_path_recordset.go index 44b6e0c..ab61c23 100644 --- a/mittwaldv2/generated/clients/domain/updaterecordset_request_path_recordset.go +++ b/mittwaldv2/generated/clients/domain/updaterecordset_request_path_recordset.go @@ -13,6 +13,7 @@ import "fmt" // - "txt" // - "srv" // - "cname" +// - "caa" type UpdateRecordSetRequestPathRecordSet string @@ -21,9 +22,10 @@ const UpdateRecordSetRequestPathRecordSetMx UpdateRecordSetRequestPathRecordSet const UpdateRecordSetRequestPathRecordSetTxt UpdateRecordSetRequestPathRecordSet = "txt" const UpdateRecordSetRequestPathRecordSetSrv UpdateRecordSetRequestPathRecordSet = "srv" const UpdateRecordSetRequestPathRecordSetCname UpdateRecordSetRequestPathRecordSet = "cname" +const UpdateRecordSetRequestPathRecordSetCaa UpdateRecordSetRequestPathRecordSet = "caa" func (e UpdateRecordSetRequestPathRecordSet) Validate() error { - if e == UpdateRecordSetRequestPathRecordSetA || e == UpdateRecordSetRequestPathRecordSetMx || e == UpdateRecordSetRequestPathRecordSetTxt || e == UpdateRecordSetRequestPathRecordSetSrv || e == UpdateRecordSetRequestPathRecordSetCname { + if e == UpdateRecordSetRequestPathRecordSetA || e == UpdateRecordSetRequestPathRecordSetMx || e == UpdateRecordSetRequestPathRecordSetTxt || e == UpdateRecordSetRequestPathRecordSetSrv || e == UpdateRecordSetRequestPathRecordSetCname || e == UpdateRecordSetRequestPathRecordSetCaa { return nil } return fmt.Errorf("unexpected value for type %T: %s", e, e) diff --git a/mittwaldv2/generated/clients/user/authenticate_response.go b/mittwaldv2/generated/clients/user/authenticate_response.go index 7c67485..a764ff1 100644 --- a/mittwaldv2/generated/clients/user/authenticate_response.go +++ b/mittwaldv2/generated/clients/user/authenticate_response.go @@ -14,17 +14,17 @@ import ( // null type AuthenticateResponse struct { - AlternativeAuthenticateAcceptedResponse *AuthenticateAcceptedResponse AlternativeAuthenticateOKResponse *AuthenticateOKResponse + AlternativeAuthenticateAcceptedResponse *AuthenticateAcceptedResponse } func (a *AuthenticateResponse) MarshalJSON() ([]byte, error) { - if a.AlternativeAuthenticateAcceptedResponse != nil { - return json.Marshal(a.AlternativeAuthenticateAcceptedResponse) - } if a.AlternativeAuthenticateOKResponse != nil { return json.Marshal(a.AlternativeAuthenticateOKResponse) } + if a.AlternativeAuthenticateAcceptedResponse != nil { + return json.Marshal(a.AlternativeAuthenticateAcceptedResponse) + } return []byte("null"), nil } @@ -35,21 +35,21 @@ func (a *AuthenticateResponse) UnmarshalJSON(input []byte) error { dec.DisallowUnknownFields() reader.Reset(input) - var alternativeAuthenticateAcceptedResponse AuthenticateAcceptedResponse - if err := dec.Decode(&alternativeAuthenticateAcceptedResponse); err == nil { + var alternativeAuthenticateOKResponse AuthenticateOKResponse + if err := dec.Decode(&alternativeAuthenticateOKResponse); err == nil { //subtype: *generator.ObjectType - if vErr := alternativeAuthenticateAcceptedResponse.Validate(); vErr == nil { - a.AlternativeAuthenticateAcceptedResponse = &alternativeAuthenticateAcceptedResponse + if vErr := alternativeAuthenticateOKResponse.Validate(); vErr == nil { + a.AlternativeAuthenticateOKResponse = &alternativeAuthenticateOKResponse decodedAtLeastOnce = true } } reader.Reset(input) - var alternativeAuthenticateOKResponse AuthenticateOKResponse - if err := dec.Decode(&alternativeAuthenticateOKResponse); err == nil { + var alternativeAuthenticateAcceptedResponse AuthenticateAcceptedResponse + if err := dec.Decode(&alternativeAuthenticateAcceptedResponse); err == nil { //subtype: *generator.ObjectType - if vErr := alternativeAuthenticateOKResponse.Validate(); vErr == nil { - a.AlternativeAuthenticateOKResponse = &alternativeAuthenticateOKResponse + if vErr := alternativeAuthenticateAcceptedResponse.Validate(); vErr == nil { + a.AlternativeAuthenticateAcceptedResponse = &alternativeAuthenticateAcceptedResponse decodedAtLeastOnce = true } } @@ -61,11 +61,11 @@ func (a *AuthenticateResponse) UnmarshalJSON(input []byte) error { } func (a *AuthenticateResponse) Validate() error { - if a.AlternativeAuthenticateAcceptedResponse != nil { - return a.AlternativeAuthenticateAcceptedResponse.Validate() - } if a.AlternativeAuthenticateOKResponse != nil { return a.AlternativeAuthenticateOKResponse.Validate() } + if a.AlternativeAuthenticateAcceptedResponse != nil { + return a.AlternativeAuthenticateAcceptedResponse.Validate() + } return errors.New("no alternative set") } diff --git a/mittwaldv2/generated/clients/user/authenticate_response_test.go b/mittwaldv2/generated/clients/user/authenticate_response_test.go index 162954c..afbd623 100644 --- a/mittwaldv2/generated/clients/user/authenticate_response_test.go +++ b/mittwaldv2/generated/clients/user/authenticate_response_test.go @@ -13,21 +13,21 @@ import ( var _ = Describe("AuthenticateResponse", func() { When("unmarshaling from JSON", func() { - It("should unmarshal into AlternativeAuthenticateAcceptedResponse", func() { - exampleJSON := []byte("{\"name\":\"SecondFactorRequired\"}") + It("should unmarshal into AlternativeAuthenticateOKResponse", func() { + exampleJSON := []byte("{\"expires\":\"2006-01-02T15:04:05Z\",\"refreshToken\":\"string\",\"token\":\"string\"}") sut := user.AuthenticateResponse{} Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) Expect(sut.Validate()).To(Succeed()) - Expect(sut.AlternativeAuthenticateAcceptedResponse).NotTo(BeNil()) + Expect(sut.AlternativeAuthenticateOKResponse).NotTo(BeNil()) }) - It("should unmarshal into AlternativeAuthenticateOKResponse", func() { - exampleJSON := []byte("{\"expires\":\"2006-01-02T15:04:05Z\",\"refreshToken\":\"string\",\"token\":\"string\"}") + It("should unmarshal into AlternativeAuthenticateAcceptedResponse", func() { + exampleJSON := []byte("{\"name\":\"SecondFactorRequired\"}") sut := user.AuthenticateResponse{} Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) Expect(sut.Validate()).To(Succeed()) - Expect(sut.AlternativeAuthenticateOKResponse).NotTo(BeNil()) + Expect(sut.AlternativeAuthenticateAcceptedResponse).NotTo(BeNil()) }) }) }) diff --git a/mittwaldv2/generated/clients/user/changepassword_response.go b/mittwaldv2/generated/clients/user/changepassword_response.go index 2f1e9c8..851e6e1 100644 --- a/mittwaldv2/generated/clients/user/changepassword_response.go +++ b/mittwaldv2/generated/clients/user/changepassword_response.go @@ -14,17 +14,17 @@ import ( // null type ChangePasswordResponse struct { - AlternativeChangePasswordAcceptedResponse *any AlternativeChangePasswordOKResponse *ChangePasswordOKResponse + AlternativeChangePasswordAcceptedResponse *any } func (a *ChangePasswordResponse) MarshalJSON() ([]byte, error) { - if a.AlternativeChangePasswordAcceptedResponse != nil { - return json.Marshal(a.AlternativeChangePasswordAcceptedResponse) - } if a.AlternativeChangePasswordOKResponse != nil { return json.Marshal(a.AlternativeChangePasswordOKResponse) } + if a.AlternativeChangePasswordAcceptedResponse != nil { + return json.Marshal(a.AlternativeChangePasswordAcceptedResponse) + } return []byte("null"), nil } @@ -34,13 +34,6 @@ func (a *ChangePasswordResponse) UnmarshalJSON(input []byte) error { dec := json.NewDecoder(reader) dec.DisallowUnknownFields() - reader.Reset(input) - var alternativeChangePasswordAcceptedResponse any - if err := dec.Decode(&alternativeChangePasswordAcceptedResponse); err == nil { - a.AlternativeChangePasswordAcceptedResponse = &alternativeChangePasswordAcceptedResponse - decodedAtLeastOnce = true - } - reader.Reset(input) var alternativeChangePasswordOKResponse ChangePasswordOKResponse if err := dec.Decode(&alternativeChangePasswordOKResponse); err == nil { @@ -51,6 +44,13 @@ func (a *ChangePasswordResponse) UnmarshalJSON(input []byte) error { } } + reader.Reset(input) + var alternativeChangePasswordAcceptedResponse any + if err := dec.Decode(&alternativeChangePasswordAcceptedResponse); err == nil { + a.AlternativeChangePasswordAcceptedResponse = &alternativeChangePasswordAcceptedResponse + decodedAtLeastOnce = true + } + if !decodedAtLeastOnce { return fmt.Errorf("could not unmarshal into any alternative for type %T", a) } @@ -58,12 +58,12 @@ func (a *ChangePasswordResponse) UnmarshalJSON(input []byte) error { } func (a *ChangePasswordResponse) Validate() error { + if a.AlternativeChangePasswordOKResponse != nil { + return a.AlternativeChangePasswordOKResponse.Validate() + } // The AlternativeChangePasswordAcceptedResponse subtype does not implement validation, so we consider being non-nil as valid if a.AlternativeChangePasswordAcceptedResponse != nil { return nil } - if a.AlternativeChangePasswordOKResponse != nil { - return a.AlternativeChangePasswordOKResponse.Validate() - } return errors.New("no alternative set") } diff --git a/mittwaldv2/generated/clients/user/changepassword_response_test.go b/mittwaldv2/generated/clients/user/changepassword_response_test.go index 2c609fb..f22d672 100644 --- a/mittwaldv2/generated/clients/user/changepassword_response_test.go +++ b/mittwaldv2/generated/clients/user/changepassword_response_test.go @@ -13,21 +13,21 @@ import ( var _ = Describe("ChangePasswordResponse", func() { When("unmarshaling from JSON", func() { - It("should unmarshal into AlternativeChangePasswordAcceptedResponse", func() { - exampleJSON := []byte("null") + It("should unmarshal into AlternativeChangePasswordOKResponse", func() { + exampleJSON := []byte("{\"expires\":\"2006-01-02T15:04:05Z\",\"token\":\"string\"}") sut := user.ChangePasswordResponse{} Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) Expect(sut.Validate()).To(Succeed()) - Expect(sut.AlternativeChangePasswordAcceptedResponse).NotTo(BeNil()) + Expect(sut.AlternativeChangePasswordOKResponse).NotTo(BeNil()) }) - It("should unmarshal into AlternativeChangePasswordOKResponse", func() { - exampleJSON := []byte("{\"expires\":\"2006-01-02T15:04:05Z\",\"token\":\"string\"}") + It("should unmarshal into AlternativeChangePasswordAcceptedResponse", func() { + exampleJSON := []byte("null") sut := user.ChangePasswordResponse{} Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) Expect(sut.Validate()).To(Succeed()) - Expect(sut.AlternativeChangePasswordOKResponse).NotTo(BeNil()) + Expect(sut.AlternativeChangePasswordAcceptedResponse).NotTo(BeNil()) }) }) }) diff --git a/mittwaldv2/generated/schemas/dnsv1/recordcaa.go b/mittwaldv2/generated/schemas/dnsv1/recordcaa.go new file mode 100644 index 0000000..2845020 --- /dev/null +++ b/mittwaldv2/generated/schemas/dnsv1/recordcaa.go @@ -0,0 +1,73 @@ +package dnsv1 + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" +) + +// This code was automatically generated by github.com/mittwald/api-client-go-builder. +// DO NOT EDIT. + +//This data type was generated from the following JSON schema: +// oneOf: +// - {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordUnset"} +// - {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCAAComponent"} + +type RecordCAA struct { + AlternativeRecordUnset *RecordUnset + AlternativeRecordCAAComponent *RecordCAAComponent +} + +func (a *RecordCAA) MarshalJSON() ([]byte, error) { + if a.AlternativeRecordUnset != nil { + return json.Marshal(a.AlternativeRecordUnset) + } + if a.AlternativeRecordCAAComponent != nil { + return json.Marshal(a.AlternativeRecordCAAComponent) + } + return []byte("null"), nil +} + +func (a *RecordCAA) UnmarshalJSON(input []byte) error { + reader := bytes.NewReader(input) + decodedAtLeastOnce := false + dec := json.NewDecoder(reader) + dec.DisallowUnknownFields() + + reader.Reset(input) + var alternativeRecordUnset RecordUnset + if err := dec.Decode(&alternativeRecordUnset); err == nil { + //subtype: *generator.ReferenceType + if vErr := alternativeRecordUnset.Validate(); vErr == nil { + a.AlternativeRecordUnset = &alternativeRecordUnset + decodedAtLeastOnce = true + } + } + + reader.Reset(input) + var alternativeRecordCAAComponent RecordCAAComponent + if err := dec.Decode(&alternativeRecordCAAComponent); err == nil { + //subtype: *generator.ReferenceType + if vErr := alternativeRecordCAAComponent.Validate(); vErr == nil { + a.AlternativeRecordCAAComponent = &alternativeRecordCAAComponent + decodedAtLeastOnce = true + } + } + + if !decodedAtLeastOnce { + return fmt.Errorf("could not unmarshal into any alternative for type %T", a) + } + return nil +} + +func (a *RecordCAA) Validate() error { + if a.AlternativeRecordUnset != nil { + return a.AlternativeRecordUnset.Validate() + } + if a.AlternativeRecordCAAComponent != nil { + return a.AlternativeRecordCAAComponent.Validate() + } + return errors.New("no alternative set") +} diff --git a/mittwaldv2/generated/schemas/dnsv1/recordcaa_test.go b/mittwaldv2/generated/schemas/dnsv1/recordcaa_test.go new file mode 100644 index 0000000..e717bfc --- /dev/null +++ b/mittwaldv2/generated/schemas/dnsv1/recordcaa_test.go @@ -0,0 +1,33 @@ +package dnsv1_test + +// This code was automatically generated by github.com/mittwald/api-client-go-builder. +// DO NOT EDIT. + +import ( + "encoding/json" + + "github.com/mittwald/api-client-go/mittwaldv2/generated/schemas/dnsv1" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("RecordCAA", func() { + When("unmarshaling from JSON", func() { + It("should unmarshal into AlternativeRecordUnset", func() { + exampleJSON := []byte("{}") + + sut := dnsv1.RecordCAA{} + Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) + Expect(sut.Validate()).To(Succeed()) + Expect(sut.AlternativeRecordUnset).NotTo(BeNil()) + }) + It("should unmarshal into AlternativeRecordCAAComponent", func() { + exampleJSON := []byte("{\"records\":[{\"flags\":42,\"tag\":\"issue\",\"value\":\"string\"}],\"settings\":{\"ttl\":{\"seconds\":42}}}") + + sut := dnsv1.RecordCAA{} + Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) + Expect(sut.Validate()).To(Succeed()) + Expect(sut.AlternativeRecordCAAComponent).NotTo(BeNil()) + }) + }) +}) diff --git a/mittwaldv2/generated/schemas/dnsv1/recordcaacomponent.go b/mittwaldv2/generated/schemas/dnsv1/recordcaacomponent.go new file mode 100644 index 0000000..fe8c221 --- /dev/null +++ b/mittwaldv2/generated/schemas/dnsv1/recordcaacomponent.go @@ -0,0 +1,47 @@ +package dnsv1 + +import ( + "errors" + "fmt" +) + +// This code was automatically generated by github.com/mittwald/api-client-go-builder. +// DO NOT EDIT. + +//This data type was generated from the following JSON schema: +// type: "object" +// properties: +// "records": +// type: "array" +// items: {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCAARecord"} +// minItems: 1 +// "settings": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordSettings"} +// required: +// - "records" +// - "settings" +// additionalProperties: false + +type RecordCAAComponent struct { + Records []RecordCAARecord `json:"records"` + Settings RecordSettings `json:"settings"` +} + +func (o *RecordCAAComponent) Validate() error { + if o.Records == nil { + return errors.New("property records is required, but not set") + } + if err := func() error { + for i := range o.Records { + if err := o.Records[i].Validate(); err != nil { + return fmt.Errorf("item %d is invalid %w", i, err) + } + } + return nil + }(); err != nil { + return fmt.Errorf("invalid property records: %w", err) + } + if err := o.Settings.Validate(); err != nil { + return fmt.Errorf("invalid property settings: %w", err) + } + return nil +} diff --git a/mittwaldv2/generated/schemas/dnsv1/recordcaacomponent_test.go b/mittwaldv2/generated/schemas/dnsv1/recordcaacomponent_test.go new file mode 100644 index 0000000..1332ddf --- /dev/null +++ b/mittwaldv2/generated/schemas/dnsv1/recordcaacomponent_test.go @@ -0,0 +1,24 @@ +package dnsv1_test + +// This code was automatically generated by github.com/mittwald/api-client-go-builder. +// DO NOT EDIT. + +import ( + "encoding/json" + + "github.com/mittwald/api-client-go/mittwaldv2/generated/schemas/dnsv1" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("RecordCAAComponent", func() { + When("unmarshaling from JSON", func() { + It("should unmarshal", func() { + exampleJSON := []byte("{\"records\":[{\"flags\":42,\"tag\":\"issue\",\"value\":\"string\"}],\"settings\":{\"ttl\":{\"seconds\":42}}}") + + sut := dnsv1.RecordCAAComponent{} + Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) + Expect(sut.Validate()).To(Succeed()) + }) + }) +}) diff --git a/mittwaldv2/generated/schemas/dnsv1/recordcaarecord.go b/mittwaldv2/generated/schemas/dnsv1/recordcaarecord.go new file mode 100644 index 0000000..b6be1e7 --- /dev/null +++ b/mittwaldv2/generated/schemas/dnsv1/recordcaarecord.go @@ -0,0 +1,41 @@ +package dnsv1 + +import "fmt" + +// This code was automatically generated by github.com/mittwald/api-client-go-builder. +// DO NOT EDIT. + +//This data type was generated from the following JSON schema: +// type: "object" +// properties: +// "flags": +// type: "integer" +// maximum: 255 +// minimum: 0 +// "tag": +// type: "string" +// enum: +// - "issue" +// - "issuewild" +// - "iodef" +// "value": +// type: "string" +// format: "idn-dnsname" +// required: +// - "flags" +// - "tag" +// - "value" +// additionalProperties: false + +type RecordCAARecord struct { + Flags int64 `json:"flags"` + Tag RecordCAARecordTag `json:"tag"` + Value string `json:"value"` +} + +func (o *RecordCAARecord) Validate() error { + if err := o.Tag.Validate(); err != nil { + return fmt.Errorf("invalid property tag: %w", err) + } + return nil +} diff --git a/mittwaldv2/generated/schemas/dnsv1/recordcaarecord_tag.go b/mittwaldv2/generated/schemas/dnsv1/recordcaarecord_tag.go new file mode 100644 index 0000000..0c096a2 --- /dev/null +++ b/mittwaldv2/generated/schemas/dnsv1/recordcaarecord_tag.go @@ -0,0 +1,26 @@ +package dnsv1 + +import "fmt" + +// This code was automatically generated by github.com/mittwald/api-client-go-builder. +// DO NOT EDIT. + +//This data type was generated from the following JSON schema: +// type: "string" +// enum: +// - "issue" +// - "issuewild" +// - "iodef" + +type RecordCAARecordTag string + +const RecordCAARecordTagIssue RecordCAARecordTag = "issue" +const RecordCAARecordTagIssuewild RecordCAARecordTag = "issuewild" +const RecordCAARecordTagIodef RecordCAARecordTag = "iodef" + +func (e RecordCAARecordTag) Validate() error { + if e == RecordCAARecordTagIssue || e == RecordCAARecordTagIssuewild || e == RecordCAARecordTagIodef { + return nil + } + return fmt.Errorf("unexpected value for type %T: %s", e, e) +} diff --git a/mittwaldv2/generated/schemas/dnsv1/recordcaarecord_test.go b/mittwaldv2/generated/schemas/dnsv1/recordcaarecord_test.go new file mode 100644 index 0000000..187ff51 --- /dev/null +++ b/mittwaldv2/generated/schemas/dnsv1/recordcaarecord_test.go @@ -0,0 +1,24 @@ +package dnsv1_test + +// This code was automatically generated by github.com/mittwald/api-client-go-builder. +// DO NOT EDIT. + +import ( + "encoding/json" + + "github.com/mittwald/api-client-go/mittwaldv2/generated/schemas/dnsv1" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +var _ = Describe("RecordCAARecord", func() { + When("unmarshaling from JSON", func() { + It("should unmarshal", func() { + exampleJSON := []byte("{\"flags\":42,\"tag\":\"issue\",\"value\":\"string\"}") + + sut := dnsv1.RecordCAARecord{} + Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) + Expect(sut.Validate()).To(Succeed()) + }) + }) +}) diff --git a/mittwaldv2/generated/schemas/dnsv1/zone.go b/mittwaldv2/generated/schemas/dnsv1/zone.go index 36318af..ad42235 100644 --- a/mittwaldv2/generated/schemas/dnsv1/zone.go +++ b/mittwaldv2/generated/schemas/dnsv1/zone.go @@ -16,6 +16,7 @@ import "fmt" // "recordSet": // type: "object" // properties: +// "caa": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCAA"} // "cname": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCNAME"} // "combinedARecords": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCombinedA"} // "mx": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordMX"} @@ -27,6 +28,7 @@ import "fmt" // - "mx" // - "txt" // - "srv" +// - "caa" // required: // - "id" // - "domain" diff --git a/mittwaldv2/generated/schemas/dnsv1/zone_recordset.go b/mittwaldv2/generated/schemas/dnsv1/zone_recordset.go index d464c50..eb28bfa 100644 --- a/mittwaldv2/generated/schemas/dnsv1/zone_recordset.go +++ b/mittwaldv2/generated/schemas/dnsv1/zone_recordset.go @@ -8,6 +8,7 @@ import "fmt" //This data type was generated from the following JSON schema: // type: "object" // properties: +// "caa": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCAA"} // "cname": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCNAME"} // "combinedARecords": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordCombinedA"} // "mx": {"$ref": "#/components/schemas/de.mittwald.v1.dns.RecordMX"} @@ -19,8 +20,10 @@ import "fmt" // - "mx" // - "txt" // - "srv" +// - "caa" type ZoneRecordSet struct { + Caa RecordCAA `json:"caa"` Cname RecordCNAME `json:"cname"` CombinedARecords RecordCombinedA `json:"combinedARecords"` Mx RecordMX `json:"mx"` @@ -29,6 +32,9 @@ type ZoneRecordSet struct { } func (o *ZoneRecordSet) Validate() error { + if err := o.Caa.Validate(); err != nil { + return fmt.Errorf("invalid property caa: %w", err) + } if err := o.Cname.Validate(); err != nil { return fmt.Errorf("invalid property cname: %w", err) } diff --git a/mittwaldv2/generated/schemas/dnsv1/zone_recordset_test.go b/mittwaldv2/generated/schemas/dnsv1/zone_recordset_test.go index 3f36c87..4949c82 100644 --- a/mittwaldv2/generated/schemas/dnsv1/zone_recordset_test.go +++ b/mittwaldv2/generated/schemas/dnsv1/zone_recordset_test.go @@ -14,7 +14,7 @@ import ( var _ = Describe("ZoneRecordSet", func() { When("unmarshaling from JSON", func() { It("should unmarshal", func() { - exampleJSON := []byte("{\"cname\":{},\"combinedARecords\":{},\"mx\":{},\"srv\":{},\"txt\":{}}") + exampleJSON := []byte("{\"caa\":{},\"cname\":{},\"combinedARecords\":{},\"mx\":{},\"srv\":{},\"txt\":{}}") sut := dnsv1.ZoneRecordSet{} Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed()) diff --git a/mittwaldv2/generated/schemas/dnsv1/zone_test.go b/mittwaldv2/generated/schemas/dnsv1/zone_test.go index b85f430..ac4983b 100644 --- a/mittwaldv2/generated/schemas/dnsv1/zone_test.go +++ b/mittwaldv2/generated/schemas/dnsv1/zone_test.go @@ -14,7 +14,7 @@ import ( var _ = Describe("Zone", func() { When("unmarshaling from JSON", func() { It("should unmarshal", func() { - exampleJSON := []byte("{\"domain\":\"string\",\"id\":\"7a9d8971-09b0-4c39-8c64-546b6e1875ce\",\"recordSet\":{\"cname\":{},\"combinedARecords\":{},\"mx\":{},\"srv\":{},\"txt\":{}}}") + exampleJSON := []byte("{\"domain\":\"string\",\"id\":\"7a9d8971-09b0-4c39-8c64-546b6e1875ce\",\"recordSet\":{\"caa\":{},\"cname\":{},\"combinedARecords\":{},\"mx\":{},\"srv\":{},\"txt\":{}}}") sut := dnsv1.Zone{} Expect(json.Unmarshal(exampleJSON, &sut)).To(Succeed())