Files
2025-05-26 16:55:15 +02:00

383 lines
11 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"
)
// Activity activity
//
// swagger:model Activity
type Activity struct {
// act user ID
ActUserID int64 `json:"act_user_id,omitempty"`
// comment ID
CommentID int64 `json:"comment_id,omitempty"`
// content
Content string `json:"content,omitempty"`
// created
// Format: date-time
Created strfmt.DateTime `json:"created,omitempty"`
// ID
ID int64 `json:"id,omitempty"`
// is private
IsPrivate bool `json:"is_private,omitempty"`
// the type of action
// Enum: ["create_repo","rename_repo","star_repo","watch_repo","commit_repo","create_issue","create_pull_request","transfer_repo","push_tag","comment_issue","merge_pull_request","close_issue","reopen_issue","close_pull_request","reopen_pull_request","delete_tag","delete_branch","mirror_sync_push","mirror_sync_create","mirror_sync_delete","approve_pull_request","reject_pull_request","comment_pull","publish_release","pull_review_dismissed","pull_request_ready_for_review","auto_merge_pull_request"]
OpType string `json:"op_type,omitempty"`
// ref name
RefName string `json:"ref_name,omitempty"`
// repo ID
RepoID int64 `json:"repo_id,omitempty"`
// user ID
UserID int64 `json:"user_id,omitempty"`
// act user
ActUser *User `json:"act_user,omitempty"`
// comment
Comment *Comment `json:"comment,omitempty"`
// repo
Repo *Repository `json:"repo,omitempty"`
}
// Validate validates this activity
func (m *Activity) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCreated(formats); err != nil {
res = append(res, err)
}
if err := m.validateOpType(formats); err != nil {
res = append(res, err)
}
if err := m.validateActUser(formats); err != nil {
res = append(res, err)
}
if err := m.validateComment(formats); err != nil {
res = append(res, err)
}
if err := m.validateRepo(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Activity) validateCreated(formats strfmt.Registry) error {
if swag.IsZero(m.Created) { // not required
return nil
}
if err := validate.FormatOf("created", "body", "date-time", m.Created.String(), formats); err != nil {
return err
}
return nil
}
var activityTypeOpTypePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["create_repo","rename_repo","star_repo","watch_repo","commit_repo","create_issue","create_pull_request","transfer_repo","push_tag","comment_issue","merge_pull_request","close_issue","reopen_issue","close_pull_request","reopen_pull_request","delete_tag","delete_branch","mirror_sync_push","mirror_sync_create","mirror_sync_delete","approve_pull_request","reject_pull_request","comment_pull","publish_release","pull_review_dismissed","pull_request_ready_for_review","auto_merge_pull_request"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
activityTypeOpTypePropEnum = append(activityTypeOpTypePropEnum, v)
}
}
const (
// ActivityOpTypeCreateRepo captures enum value "create_repo"
ActivityOpTypeCreateRepo string = "create_repo"
// ActivityOpTypeRenameRepo captures enum value "rename_repo"
ActivityOpTypeRenameRepo string = "rename_repo"
// ActivityOpTypeStarRepo captures enum value "star_repo"
ActivityOpTypeStarRepo string = "star_repo"
// ActivityOpTypeWatchRepo captures enum value "watch_repo"
ActivityOpTypeWatchRepo string = "watch_repo"
// ActivityOpTypeCommitRepo captures enum value "commit_repo"
ActivityOpTypeCommitRepo string = "commit_repo"
// ActivityOpTypeCreateIssue captures enum value "create_issue"
ActivityOpTypeCreateIssue string = "create_issue"
// ActivityOpTypeCreatePullRequest captures enum value "create_pull_request"
ActivityOpTypeCreatePullRequest string = "create_pull_request"
// ActivityOpTypeTransferRepo captures enum value "transfer_repo"
ActivityOpTypeTransferRepo string = "transfer_repo"
// ActivityOpTypePushTag captures enum value "push_tag"
ActivityOpTypePushTag string = "push_tag"
// ActivityOpTypeCommentIssue captures enum value "comment_issue"
ActivityOpTypeCommentIssue string = "comment_issue"
// ActivityOpTypeMergePullRequest captures enum value "merge_pull_request"
ActivityOpTypeMergePullRequest string = "merge_pull_request"
// ActivityOpTypeCloseIssue captures enum value "close_issue"
ActivityOpTypeCloseIssue string = "close_issue"
// ActivityOpTypeReopenIssue captures enum value "reopen_issue"
ActivityOpTypeReopenIssue string = "reopen_issue"
// ActivityOpTypeClosePullRequest captures enum value "close_pull_request"
ActivityOpTypeClosePullRequest string = "close_pull_request"
// ActivityOpTypeReopenPullRequest captures enum value "reopen_pull_request"
ActivityOpTypeReopenPullRequest string = "reopen_pull_request"
// ActivityOpTypeDeleteTag captures enum value "delete_tag"
ActivityOpTypeDeleteTag string = "delete_tag"
// ActivityOpTypeDeleteBranch captures enum value "delete_branch"
ActivityOpTypeDeleteBranch string = "delete_branch"
// ActivityOpTypeMirrorSyncPush captures enum value "mirror_sync_push"
ActivityOpTypeMirrorSyncPush string = "mirror_sync_push"
// ActivityOpTypeMirrorSyncCreate captures enum value "mirror_sync_create"
ActivityOpTypeMirrorSyncCreate string = "mirror_sync_create"
// ActivityOpTypeMirrorSyncDelete captures enum value "mirror_sync_delete"
ActivityOpTypeMirrorSyncDelete string = "mirror_sync_delete"
// ActivityOpTypeApprovePullRequest captures enum value "approve_pull_request"
ActivityOpTypeApprovePullRequest string = "approve_pull_request"
// ActivityOpTypeRejectPullRequest captures enum value "reject_pull_request"
ActivityOpTypeRejectPullRequest string = "reject_pull_request"
// ActivityOpTypeCommentPull captures enum value "comment_pull"
ActivityOpTypeCommentPull string = "comment_pull"
// ActivityOpTypePublishRelease captures enum value "publish_release"
ActivityOpTypePublishRelease string = "publish_release"
// ActivityOpTypePullReviewDismissed captures enum value "pull_review_dismissed"
ActivityOpTypePullReviewDismissed string = "pull_review_dismissed"
// ActivityOpTypePullRequestReadyForReview captures enum value "pull_request_ready_for_review"
ActivityOpTypePullRequestReadyForReview string = "pull_request_ready_for_review"
// ActivityOpTypeAutoMergePullRequest captures enum value "auto_merge_pull_request"
ActivityOpTypeAutoMergePullRequest string = "auto_merge_pull_request"
)
// prop value enum
func (m *Activity) validateOpTypeEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, activityTypeOpTypePropEnum, true); err != nil {
return err
}
return nil
}
func (m *Activity) validateOpType(formats strfmt.Registry) error {
if swag.IsZero(m.OpType) { // not required
return nil
}
// value enum
if err := m.validateOpTypeEnum("op_type", "body", m.OpType); err != nil {
return err
}
return nil
}
func (m *Activity) validateActUser(formats strfmt.Registry) error {
if swag.IsZero(m.ActUser) { // not required
return nil
}
if m.ActUser != nil {
if err := m.ActUser.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("act_user")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("act_user")
}
return err
}
}
return nil
}
func (m *Activity) validateComment(formats strfmt.Registry) error {
if swag.IsZero(m.Comment) { // not required
return nil
}
if m.Comment != nil {
if err := m.Comment.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("comment")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("comment")
}
return err
}
}
return nil
}
func (m *Activity) validateRepo(formats strfmt.Registry) error {
if swag.IsZero(m.Repo) { // not required
return nil
}
if m.Repo != nil {
if err := m.Repo.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("repo")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("repo")
}
return err
}
}
return nil
}
// ContextValidate validate this activity based on the context it is used
func (m *Activity) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateActUser(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateComment(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRepo(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Activity) contextValidateActUser(ctx context.Context, formats strfmt.Registry) error {
if m.ActUser != nil {
if swag.IsZero(m.ActUser) { // not required
return nil
}
if err := m.ActUser.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("act_user")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("act_user")
}
return err
}
}
return nil
}
func (m *Activity) contextValidateComment(ctx context.Context, formats strfmt.Registry) error {
if m.Comment != nil {
if swag.IsZero(m.Comment) { // not required
return nil
}
if err := m.Comment.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("comment")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("comment")
}
return err
}
}
return nil
}
func (m *Activity) contextValidateRepo(ctx context.Context, formats strfmt.Registry) error {
if m.Repo != nil {
if swag.IsZero(m.Repo) { // not required
return nil
}
if err := m.Repo.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("repo")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("repo")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *Activity) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *Activity) UnmarshalBinary(b []byte) error {
var res Activity
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}