autogits/bots-common/gitea-generated/models/create_hook_option.go
Adam Majer 598ecbbd5a .
2024-07-07 21:12:40 +02:00

195 lines
4.9 KiB
Go

// 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 (
"context"
"encoding/json"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// CreateHookOption CreateHookOption options when create a hook
//
// swagger:model CreateHookOption
type CreateHookOption struct {
// active
Active *bool `json:"active,omitempty"`
// authorization header
AuthorizationHeader string `json:"authorization_header,omitempty"`
// branch filter
BranchFilter string `json:"branch_filter,omitempty"`
// events
Events []string `json:"events"`
// type
// Required: true
// Enum: ["dingtalk","discord","gitea","gogs","msteams","slack","telegram","feishu","wechatwork","packagist"]
Type *string `json:"type"`
// config
// Required: true
Config CreateHookOptionConfig `json:"config"`
}
// Validate validates this create hook option
func (m *CreateHookOption) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateType(formats); err != nil {
res = append(res, err)
}
if err := m.validateConfig(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var createHookOptionTypeTypePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["dingtalk","discord","gitea","gogs","msteams","slack","telegram","feishu","wechatwork","packagist"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
createHookOptionTypeTypePropEnum = append(createHookOptionTypeTypePropEnum, v)
}
}
const (
// CreateHookOptionTypeDingtalk captures enum value "dingtalk"
CreateHookOptionTypeDingtalk string = "dingtalk"
// CreateHookOptionTypeDiscord captures enum value "discord"
CreateHookOptionTypeDiscord string = "discord"
// CreateHookOptionTypeGitea captures enum value "gitea"
CreateHookOptionTypeGitea string = "gitea"
// CreateHookOptionTypeGogs captures enum value "gogs"
CreateHookOptionTypeGogs string = "gogs"
// CreateHookOptionTypeMsteams captures enum value "msteams"
CreateHookOptionTypeMsteams string = "msteams"
// CreateHookOptionTypeSlack captures enum value "slack"
CreateHookOptionTypeSlack string = "slack"
// CreateHookOptionTypeTelegram captures enum value "telegram"
CreateHookOptionTypeTelegram string = "telegram"
// CreateHookOptionTypeFeishu captures enum value "feishu"
CreateHookOptionTypeFeishu string = "feishu"
// CreateHookOptionTypeWechatwork captures enum value "wechatwork"
CreateHookOptionTypeWechatwork string = "wechatwork"
// CreateHookOptionTypePackagist captures enum value "packagist"
CreateHookOptionTypePackagist string = "packagist"
)
// prop value enum
func (m *CreateHookOption) validateTypeEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, createHookOptionTypeTypePropEnum, true); err != nil {
return err
}
return nil
}
func (m *CreateHookOption) validateType(formats strfmt.Registry) error {
if err := validate.Required("type", "body", m.Type); err != nil {
return err
}
// value enum
if err := m.validateTypeEnum("type", "body", *m.Type); err != nil {
return err
}
return nil
}
func (m *CreateHookOption) validateConfig(formats strfmt.Registry) error {
if err := validate.Required("config", "body", m.Config); err != nil {
return err
}
if m.Config != nil {
if err := m.Config.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("config")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("config")
}
return err
}
}
return nil
}
// ContextValidate validate this create hook option based on the context it is used
func (m *CreateHookOption) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateConfig(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *CreateHookOption) contextValidateConfig(ctx context.Context, formats strfmt.Registry) error {
if err := m.Config.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("config")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("config")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *CreateHookOption) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *CreateHookOption) UnmarshalBinary(b []byte) error {
var res CreateHookOption
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}