diff --git a/pkg/generated/models/subscription_attributes.go b/pkg/generated/models/subscription_attributes.go index 2a6b8cd9..a3452535 100644 --- a/pkg/generated/models/subscription_attributes.go +++ b/pkg/generated/models/subscription_attributes.go @@ -48,6 +48,10 @@ type SubscriptionAttributes struct { // Pattern: ^[A-Za-z_-]*$ RecordType *string `json:"record_type"` + // All purpose list of key-value pairs to store specific data for the associated subscription. + // Max Items: 5 + UserDefinedData []*SubscriptionUserDefinedData `json:"user_defined_data,omitempty"` + // user id // Read Only: true // Format: uuid @@ -71,6 +75,8 @@ func SubscriptionAttributesWithDefaults(defaults client.Defaults) *SubscriptionA RecordType: defaults.GetStringPtr("SubscriptionAttributes", "record_type"), + UserDefinedData: make([]*SubscriptionUserDefinedData, 0), + UserID: defaults.GetStrfmtUUID("SubscriptionAttributes", "user_id"), } } @@ -134,6 +140,13 @@ func (m *SubscriptionAttributes) WithoutRecordType() *SubscriptionAttributes { return m } +func (m *SubscriptionAttributes) WithUserDefinedData(userDefinedData []*SubscriptionUserDefinedData) *SubscriptionAttributes { + + m.UserDefinedData = userDefinedData + + return m +} + func (m *SubscriptionAttributes) WithUserID(userID strfmt.UUID) *SubscriptionAttributes { m.UserID = userID @@ -165,6 +178,10 @@ func (m *SubscriptionAttributes) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUserDefinedData(formats); err != nil { + res = append(res, err) + } + if err := m.validateUserID(formats); err != nil { res = append(res, err) } @@ -255,6 +272,37 @@ func (m *SubscriptionAttributes) validateRecordType(formats strfmt.Registry) err return nil } +func (m *SubscriptionAttributes) validateUserDefinedData(formats strfmt.Registry) error { + + if swag.IsZero(m.UserDefinedData) { // not required + return nil + } + + iUserDefinedDataSize := int64(len(m.UserDefinedData)) + + if err := validate.MaxItems("user_defined_data", "body", iUserDefinedDataSize, 5); err != nil { + return err + } + + for i := 0; i < len(m.UserDefinedData); i++ { + if swag.IsZero(m.UserDefinedData[i]) { // not required + continue + } + + if m.UserDefinedData[i] != nil { + if err := m.UserDefinedData[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("user_defined_data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *SubscriptionAttributes) validateUserID(formats strfmt.Registry) error { if swag.IsZero(m.UserID) { // not required diff --git a/pkg/generated/models/subscription_update_attributes.go b/pkg/generated/models/subscription_update_attributes.go index 4a660f5b..009ef662 100644 --- a/pkg/generated/models/subscription_update_attributes.go +++ b/pkg/generated/models/subscription_update_attributes.go @@ -46,6 +46,10 @@ type SubscriptionUpdateAttributes struct { // Pattern: ^[A-Za-z_-]*$ RecordType string `json:"record_type,omitempty"` + // All purpose list of key-value pairs to store specific data for the associated subscription. + // Max Items: 5 + UserDefinedData []*SubscriptionUserDefinedData `json:"user_defined_data,omitempty"` + // user id // Read Only: true // Format: uuid @@ -69,6 +73,8 @@ func SubscriptionUpdateAttributesWithDefaults(defaults client.Defaults) *Subscri RecordType: defaults.GetString("SubscriptionUpdateAttributes", "record_type"), + UserDefinedData: make([]*SubscriptionUserDefinedData, 0), + UserID: defaults.GetStrfmtUUID("SubscriptionUpdateAttributes", "user_id"), } } @@ -122,6 +128,13 @@ func (m *SubscriptionUpdateAttributes) WithRecordType(recordType string) *Subscr return m } +func (m *SubscriptionUpdateAttributes) WithUserDefinedData(userDefinedData []*SubscriptionUserDefinedData) *SubscriptionUpdateAttributes { + + m.UserDefinedData = userDefinedData + + return m +} + func (m *SubscriptionUpdateAttributes) WithUserID(userID strfmt.UUID) *SubscriptionUpdateAttributes { m.UserID = userID @@ -153,6 +166,10 @@ func (m *SubscriptionUpdateAttributes) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateUserDefinedData(formats); err != nil { + res = append(res, err) + } + if err := m.validateUserID(formats); err != nil { res = append(res, err) } @@ -243,6 +260,37 @@ func (m *SubscriptionUpdateAttributes) validateRecordType(formats strfmt.Registr return nil } +func (m *SubscriptionUpdateAttributes) validateUserDefinedData(formats strfmt.Registry) error { + + if swag.IsZero(m.UserDefinedData) { // not required + return nil + } + + iUserDefinedDataSize := int64(len(m.UserDefinedData)) + + if err := validate.MaxItems("user_defined_data", "body", iUserDefinedDataSize, 5); err != nil { + return err + } + + for i := 0; i < len(m.UserDefinedData); i++ { + if swag.IsZero(m.UserDefinedData[i]) { // not required + continue + } + + if m.UserDefinedData[i] != nil { + if err := m.UserDefinedData[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("user_defined_data" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *SubscriptionUpdateAttributes) validateUserID(formats strfmt.Registry) error { if swag.IsZero(m.UserID) { // not required diff --git a/pkg/generated/models/subscription_user_defined_data.go b/pkg/generated/models/subscription_user_defined_data.go new file mode 100644 index 00000000..534cf711 --- /dev/null +++ b/pkg/generated/models/subscription_user_defined_data.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "log" + + "github.com/form3tech-oss/go-form3/v6/pkg/client" + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// SubscriptionUserDefinedData subscription user defined data +// swagger:model SubscriptionUserDefinedData +type SubscriptionUserDefinedData struct { + + // A user-defined key, up to 45 characters. An entry always contains both `key` and `value` fields. + // Required: true + // Max Length: 45 + // Min Length: 1 + Key *string `json:"key"` + + // A user-defined value, up to 45 characters. An entry always contains both `key` and `value` fields. + // Required: true + // Max Length: 45 + // Min Length: 1 + Value *string `json:"value"` +} + +func SubscriptionUserDefinedDataWithDefaults(defaults client.Defaults) *SubscriptionUserDefinedData { + return &SubscriptionUserDefinedData{ + + Key: defaults.GetStringPtr("SubscriptionUserDefinedData", "key"), + + Value: defaults.GetStringPtr("SubscriptionUserDefinedData", "value"), + } +} + +func (m *SubscriptionUserDefinedData) WithKey(key string) *SubscriptionUserDefinedData { + + m.Key = &key + + return m +} + +func (m *SubscriptionUserDefinedData) WithoutKey() *SubscriptionUserDefinedData { + m.Key = nil + return m +} + +func (m *SubscriptionUserDefinedData) WithValue(value string) *SubscriptionUserDefinedData { + + m.Value = &value + + return m +} + +func (m *SubscriptionUserDefinedData) WithoutValue() *SubscriptionUserDefinedData { + m.Value = nil + return m +} + +// Validate validates this subscription user defined data +func (m *SubscriptionUserDefinedData) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateKey(formats); err != nil { + res = append(res, err) + } + + if err := m.validateValue(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *SubscriptionUserDefinedData) validateKey(formats strfmt.Registry) error { + + if err := validate.Required("key", "body", m.Key); err != nil { + return err + } + + if err := validate.MinLength("key", "body", string(*m.Key), 1); err != nil { + return err + } + + if err := validate.MaxLength("key", "body", string(*m.Key), 45); err != nil { + return err + } + + return nil +} + +func (m *SubscriptionUserDefinedData) validateValue(formats strfmt.Registry) error { + + if err := validate.Required("value", "body", m.Value); err != nil { + return err + } + + if err := validate.MinLength("value", "body", string(*m.Value), 1); err != nil { + return err + } + + if err := validate.MaxLength("value", "body", string(*m.Value), 45); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *SubscriptionUserDefinedData) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SubscriptionUserDefinedData) UnmarshalBinary(b []byte) error { + var res SubscriptionUserDefinedData + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} +func (m *SubscriptionUserDefinedData) Json() string { + json, err := json.MarshalIndent(m, " ", " ") + if err != nil { + log.Fatal(err) + } + return string(json) +}