// 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"
)

// MigrateRepoOptions MigrateRepoOptions options for migrating repository's
// this is used to interact with api v1
//
// swagger:model MigrateRepoOptions
type MigrateRepoOptions struct {

	// auth password
	AuthPassword string `json:"auth_password,omitempty"`

	// auth token
	AuthToken string `json:"auth_token,omitempty"`

	// auth username
	AuthUsername string `json:"auth_username,omitempty"`

	// clone addr
	// Required: true
	CloneAddr *string `json:"clone_addr"`

	// description
	Description string `json:"description,omitempty"`

	// issues
	Issues bool `json:"issues,omitempty"`

	// l f s
	LFS bool `json:"lfs,omitempty"`

	// l f s endpoint
	LFSEndpoint string `json:"lfs_endpoint,omitempty"`

	// labels
	Labels bool `json:"labels,omitempty"`

	// milestones
	Milestones bool `json:"milestones,omitempty"`

	// mirror
	Mirror bool `json:"mirror,omitempty"`

	// mirror interval
	MirrorInterval string `json:"mirror_interval,omitempty"`

	// private
	Private bool `json:"private,omitempty"`

	// pull requests
	PullRequests bool `json:"pull_requests,omitempty"`

	// releases
	Releases bool `json:"releases,omitempty"`

	// repo name
	// Required: true
	RepoName *string `json:"repo_name"`

	// Name of User or Organisation who will own Repo after migration
	RepoOwner string `json:"repo_owner,omitempty"`

	// deprecated (only for backwards compatibility)
	RepoOwnerID int64 `json:"uid,omitempty"`

	// service
	// Enum: ["git","github","gitea","gitlab","gogs","onedev","gitbucket","codebase"]
	Service string `json:"service,omitempty"`

	// wiki
	Wiki bool `json:"wiki,omitempty"`
}

// Validate validates this migrate repo options
func (m *MigrateRepoOptions) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateCloneAddr(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateRepoName(formats); err != nil {
		res = append(res, err)
	}

	if err := m.validateService(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}

func (m *MigrateRepoOptions) validateCloneAddr(formats strfmt.Registry) error {

	if err := validate.Required("clone_addr", "body", m.CloneAddr); err != nil {
		return err
	}

	return nil
}

func (m *MigrateRepoOptions) validateRepoName(formats strfmt.Registry) error {

	if err := validate.Required("repo_name", "body", m.RepoName); err != nil {
		return err
	}

	return nil
}

var migrateRepoOptionsTypeServicePropEnum []interface{}

func init() {
	var res []string
	if err := json.Unmarshal([]byte(`["git","github","gitea","gitlab","gogs","onedev","gitbucket","codebase"]`), &res); err != nil {
		panic(err)
	}
	for _, v := range res {
		migrateRepoOptionsTypeServicePropEnum = append(migrateRepoOptionsTypeServicePropEnum, v)
	}
}

const (

	// MigrateRepoOptionsServiceGit captures enum value "git"
	MigrateRepoOptionsServiceGit string = "git"

	// MigrateRepoOptionsServiceGithub captures enum value "github"
	MigrateRepoOptionsServiceGithub string = "github"

	// MigrateRepoOptionsServiceGitea captures enum value "gitea"
	MigrateRepoOptionsServiceGitea string = "gitea"

	// MigrateRepoOptionsServiceGitlab captures enum value "gitlab"
	MigrateRepoOptionsServiceGitlab string = "gitlab"

	// MigrateRepoOptionsServiceGogs captures enum value "gogs"
	MigrateRepoOptionsServiceGogs string = "gogs"

	// MigrateRepoOptionsServiceOnedev captures enum value "onedev"
	MigrateRepoOptionsServiceOnedev string = "onedev"

	// MigrateRepoOptionsServiceGitbucket captures enum value "gitbucket"
	MigrateRepoOptionsServiceGitbucket string = "gitbucket"

	// MigrateRepoOptionsServiceCodebase captures enum value "codebase"
	MigrateRepoOptionsServiceCodebase string = "codebase"
)

// prop value enum
func (m *MigrateRepoOptions) validateServiceEnum(path, location string, value string) error {
	if err := validate.EnumCase(path, location, value, migrateRepoOptionsTypeServicePropEnum, true); err != nil {
		return err
	}
	return nil
}

func (m *MigrateRepoOptions) validateService(formats strfmt.Registry) error {
	if swag.IsZero(m.Service) { // not required
		return nil
	}

	// value enum
	if err := m.validateServiceEnum("service", "body", m.Service); err != nil {
		return err
	}

	return nil
}

// ContextValidate validates this migrate repo options based on context it is used
func (m *MigrateRepoOptions) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
	return nil
}

// MarshalBinary interface implementation
func (m *MigrateRepoOptions) MarshalBinary() ([]byte, error) {
	if m == nil {
		return nil, nil
	}
	return swag.WriteJSON(m)
}

// UnmarshalBinary interface implementation
func (m *MigrateRepoOptions) UnmarshalBinary(b []byte) error {
	var res MigrateRepoOptions
	if err := swag.ReadJSON(b, &res); err != nil {
		return err
	}
	*m = res
	return nil
}
