package jump

import (
	"github.com/tidbcloud/devops/api"
	jmpent "github.com/tidbcloud/devops/entity/jump"
)

type ListAuthorizationsReq struct {
	api.PaginationReq

	Type              *string                    `form:"type"`
	Phase             *jmpent.AuthorizationPhase `form:"phase"`
	Applicant         *string                    `form:"applicant"`
	DestinationTypeIs *jmpent.DestinationType    `form:"destination_type_is"`
	DestinationIDLike *string                    `form:"destination_id_like"`

	ShowUnaccessible *bool `form:"show_unaccessible"`
}

type ListAuthorizationsResp struct {
	api.BaseResp `json:",inline"`

	Total          int64                   `json:"total"`
	Authorizations []*jmpent.Authorization `json:"items"`
}

type GetAuthorizationReq struct {
}

type GetAuthorizationResp struct {
	api.BaseResp `json:",inline"`

	Authorization *jmpent.Authorization `json:"authorization"`
}

type CreateAuthorizationReq struct {
	DestinationType     jmpent.DestinationType `json:"destination_type"`
	Destinations        []string               `json:"destinations"`
	Privilege           jmpent.JumpPrivilege   `json:"privilege"`
	Expiration          jmpent.JumpExpiration  `json:"expiration"`
	Reason              string                 `json:"reason"`
	EnableGatewayAccess bool                   `json:"enable_gateway_access"`
	Extra               map[string]string      `json:"extra,omitempty"`
}

type CreateAuthorizationResp struct {
	api.BaseResp

	AuthorizationID *uint64 `json:"authorization_id"`
}

type CancelAuthorizationReq struct {
	Force   bool `json:"force"`
	Timeout int  `json:"timeout"`
}

type GetConnectJumpPodParamsResp struct {
	api.BaseResp `json:",inline"`

	Params *jmpent.JumppodConnectParam `json:"params"`
}

type ListAvailableDestinationsResp struct {
	api.BaseResp `json:",inline"`

	Destinations []string `json:"destinations"`
}

type GetConnectionRequest struct {
	Method jmpent.ConnectionMethod `form:"method" binding:"required"`
}

type GetConnectionResponse struct {
	api.BaseResp `json:",inline"`

	Connection *jmpent.Connection `json:"connection"`
}
