// 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" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" ) // Attachment Attachment models a media attachment. // // swagger:model Attachment type Attachment struct { // A hash computed by the BlurHash algorithm, for generating colorful preview thumbnails when media has not been downloaded yet. // See https://github.com/woltapp/blurhash Blurhash string `json:"blurhash,omitempty"` // Alt text that describes what is in the media attachment. // Example: This is a picture of a kitten. Description string `json:"description,omitempty"` // The ID of the attachment. // Example: 01FC31DZT1AYWDZ8XTCRWRBYRK ID string `json:"id,omitempty"` // The location of a scaled-down preview of the attachment on the remote server. // Only defined for instances other than our own. // Example: https://some-other-server.org/attachments/small/ahhhhh.jpeg PreviewRemoteURL string `json:"preview_remote_url,omitempty"` // The location of a scaled-down preview of the attachment. // Example: https://example.org/fileserver/some_id/attachments/some_id/small/attachment.jpeg PreviewURL string `json:"preview_url,omitempty"` // The location of the full-size original attachment on the remote server. // Only defined for instances other than our own. // Example: https://some-other-server.org/attachments/original/ahhhhh.jpeg RemoteURL string `json:"remote_url,omitempty"` // A shorter URL for the attachment. // In our case, we just give the URL again since we don't create smaller URLs. TextURL string `json:"text_url,omitempty"` // The type of the attachment. // Example: image Type string `json:"type,omitempty"` // The location of the original full-size attachment. // Example: https://example.org/fileserver/some_id/attachments/some_id/original/attachment.jpeg URL string `json:"url,omitempty"` // meta Meta *MediaMeta `json:"meta,omitempty"` } // Validate validates this attachment func (m *Attachment) Validate(formats strfmt.Registry) error { var res []error if err := m.validateMeta(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *Attachment) validateMeta(formats strfmt.Registry) error { if swag.IsZero(m.Meta) { // not required return nil } if m.Meta != nil { if err := m.Meta.Validate(formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("meta") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("meta") } return err } } return nil } // ContextValidate validate this attachment based on the context it is used func (m *Attachment) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error if err := m.contextValidateMeta(ctx, formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } func (m *Attachment) contextValidateMeta(ctx context.Context, formats strfmt.Registry) error { if m.Meta != nil { if swag.IsZero(m.Meta) { // not required return nil } if err := m.Meta.ContextValidate(ctx, formats); err != nil { if ve, ok := err.(*errors.Validation); ok { return ve.ValidateName("meta") } else if ce, ok := err.(*errors.CompositeError); ok { return ce.ValidateName("meta") } return err } } return nil } // MarshalBinary interface implementation func (m *Attachment) MarshalBinary() ([]byte, error) { if m == nil { return nil, nil } return swag.WriteJSON(m) } // UnmarshalBinary interface implementation func (m *Attachment) UnmarshalBinary(b []byte) error { var res Attachment if err := swag.ReadJSON(b, &res); err != nil { return err } *m = res return nil }