db

package
v0.0.0-...-0be37f2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateNewRequestParams

type CreateNewRequestParams struct {
	UserID       pgtype.Int8        `json:"user_id"`
	EndpointID   int64              `json:"endpoint_id"`
	Path         string             `json:"path"`
	FormData     []byte             `json:"form_data"`
	ContentType  string             `json:"content_type"`
	ResponseID   pgtype.Int8        `json:"response_id"`
	Content      pgtype.Text        `json:"content"`
	Method       HttpMethod         `json:"method"`
	Uuid         string             `json:"uuid"`
	SourceIp     string             `json:"source_ip"`
	ContentSize  int32              `json:"content_size"`
	ResponseCode pgtype.Int4        `json:"response_code"`
	Headers      []byte             `json:"headers"`
	QueryParams  []byte             `json:"query_params"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
}

type CreateUserParams

type CreateUserParams struct {
	Name      string `json:"name"`
	AvatarUrl string `json:"avatar_url"`
	Username  string `json:"username"`
	Plan      Plan   `json:"plan"`
	Email     string `json:"email"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type Endpoint

type Endpoint struct {
	ID        int64              `json:"id"`
	Endpoint  string             `json:"endpoint"`
	UserID    pgtype.Int8        `json:"user_id"`
	Plan      Plan               `json:"plan"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	IsDeleted pgtype.Bool        `json:"is_deleted"`
}

type FileAttachment

type FileAttachment struct {
	ID         int64              `json:"id"`
	Uri        string             `json:"uri"`
	EndpointID int64              `json:"endpoint_id"`
	UserID     pgtype.Int8        `json:"user_id"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
	IsDeleted  pgtype.Bool        `json:"is_deleted"`
}

type GetEndpointHistoryParams

type GetEndpointHistoryParams struct {
	Endpoint string      `json:"endpoint"`
	UserID   pgtype.Int8 `json:"user_id"`
	Limit    int32       `json:"limit"`
	Offset   int32       `json:"offset"`
}

type GetEndpointHistoryRow

type GetEndpointHistoryRow struct {
	ID           int64              `json:"id"`
	Uuid         string             `json:"uuid"`
	UserID       pgtype.Int8        `json:"user_id"`
	Plan         Plan               `json:"plan"`
	Path         string             `json:"path"`
	ResponseID   pgtype.Int8        `json:"response_id"`
	ResponseCode pgtype.Int4        `json:"response_code"`
	FormData     []byte             `json:"form_data"`
	ContentType  string             `json:"content_type"`
	Content      pgtype.Text        `json:"content"`
	Method       HttpMethod         `json:"method"`
	SourceIp     string             `json:"source_ip"`
	ContentSize  int32              `json:"content_size"`
	Headers      []byte             `json:"headers"`
	QueryParams  []byte             `json:"query_params"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
	Endpoint     pgtype.Text        `json:"endpoint"`
}

type GetEndpointRequestCountRow

type GetEndpointRequestCountRow struct {
	TotalCount   int64 `json:"total_count"`
	SuccessCount int64 `json:"success_count"`
	FailureCount int64 `json:"failure_count"`
}

type HttpMethod

type HttpMethod string
const (
	HttpMethodGet     HttpMethod = "get"
	HttpMethodPost    HttpMethod = "post"
	HttpMethodPut     HttpMethod = "put"
	HttpMethodPatch   HttpMethod = "patch"
	HttpMethodDelete  HttpMethod = "delete"
	HttpMethodOptions HttpMethod = "options"
	HttpMethodHead    HttpMethod = "head"
	HttpMethodTrace   HttpMethod = "trace"
	HttpMethodConnect HttpMethod = "connect"
)

func (*HttpMethod) Scan

func (e *HttpMethod) Scan(src interface{}) error

type InsertEndpointParams

type InsertEndpointParams struct {
	Endpoint  string             `json:"endpoint"`
	UserID    pgtype.Int8        `json:"user_id"`
	Plan      Plan               `json:"plan"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
}

type InsertFreeEndpointParams

type InsertFreeEndpointParams struct {
	Endpoint  string             `json:"endpoint"`
	UserID    pgtype.Int8        `json:"user_id"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
}

type ListUsersParams

type ListUsersParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type NullHttpMethod

type NullHttpMethod struct {
	HttpMethod HttpMethod `json:"http_method"`
	Valid      bool       `json:"valid"` // Valid is true if HttpMethod is not NULL
}

func (*NullHttpMethod) Scan

func (ns *NullHttpMethod) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullHttpMethod) Value

func (ns NullHttpMethod) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullPlan

type NullPlan struct {
	Plan  Plan `json:"plan"`
	Valid bool `json:"valid"` // Valid is true if Plan is not NULL
}

func (*NullPlan) Scan

func (ns *NullPlan) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullPlan) Value

func (ns NullPlan) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Plan

type Plan string
const (
	PlanFree  Plan = "free"
	PlanBasic Plan = "basic"
	PlanPro   Plan = "pro"
)

func (*Plan) Scan

func (e *Plan) Scan(src interface{}) error

type Querier

type Querier interface {
	CheckEndpointExists(ctx context.Context, endpoint string) (bool, error)
	CreateNewRequest(ctx context.Context, arg CreateNewRequestParams) (Request, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteExpiredRequests(ctx context.Context) error
	DeleteUser(ctx context.Context, id int64) error
	GetEndpointDetails(ctx context.Context, endpoint string) (Endpoint, error)
	GetEndpointHistory(ctx context.Context, arg GetEndpointHistoryParams) ([]GetEndpointHistoryRow, error)
	GetEndpointRequestCount(ctx context.Context, endpoint string) (GetEndpointRequestCountRow, error)
	GetNonExpiredEndpointsOfUser(ctx context.Context, userID pgtype.Int8) ([]Endpoint, error)
	GetRequestById(ctx context.Context, id int64) (Request, error)
	GetRequestByUUID(ctx context.Context, uuid string) (Request, error)
	GetUser(ctx context.Context, id int64) (User, error)
	GetUserEndpoints(ctx context.Context, userID pgtype.Int8) ([]Endpoint, error)
	GetUserFromEmail(ctx context.Context, email string) (User, error)
	GetUserFromUsername(ctx context.Context, username string) (User, error)
	InsertEndpoint(ctx context.Context, arg InsertEndpointParams) (Endpoint, error)
	InsertFreeEndpoint(ctx context.Context, arg InsertFreeEndpointParams) (Endpoint, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CheckEndpointExists

func (q *Queries) CheckEndpointExists(ctx context.Context, endpoint string) (bool, error)

func (*Queries) CreateNewRequest

func (q *Queries) CreateNewRequest(ctx context.Context, arg CreateNewRequestParams) (Request, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) DeleteExpiredRequests

func (q *Queries) DeleteExpiredRequests(ctx context.Context) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id int64) error

func (*Queries) GetEndpointDetails

func (q *Queries) GetEndpointDetails(ctx context.Context, endpoint string) (Endpoint, error)

func (*Queries) GetEndpointHistory

func (q *Queries) GetEndpointHistory(ctx context.Context, arg GetEndpointHistoryParams) ([]GetEndpointHistoryRow, error)

func (*Queries) GetEndpointRequestCount

func (q *Queries) GetEndpointRequestCount(ctx context.Context, endpoint string) (GetEndpointRequestCountRow, error)

func (*Queries) GetNonExpiredEndpointsOfUser

func (q *Queries) GetNonExpiredEndpointsOfUser(ctx context.Context, userID pgtype.Int8) ([]Endpoint, error)

func (*Queries) GetRequestById

func (q *Queries) GetRequestById(ctx context.Context, id int64) (Request, error)

func (*Queries) GetRequestByUUID

func (q *Queries) GetRequestByUUID(ctx context.Context, uuid string) (Request, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int64) (User, error)

func (*Queries) GetUserEndpoints

func (q *Queries) GetUserEndpoints(ctx context.Context, userID pgtype.Int8) ([]Endpoint, error)

func (*Queries) GetUserFromEmail

func (q *Queries) GetUserFromEmail(ctx context.Context, email string) (User, error)

func (*Queries) GetUserFromUsername

func (q *Queries) GetUserFromUsername(ctx context.Context, username string) (User, error)

func (*Queries) InsertEndpoint

func (q *Queries) InsertEndpoint(ctx context.Context, arg InsertEndpointParams) (Endpoint, error)

func (*Queries) InsertFreeEndpoint

func (q *Queries) InsertFreeEndpoint(ctx context.Context, arg InsertFreeEndpointParams) (Endpoint, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type Request

type Request struct {
	ID           int64       `json:"id"`
	Uuid         string      `json:"uuid"`
	UserID       pgtype.Int8 `json:"user_id"`
	EndpointID   int64       `json:"endpoint_id"`
	Plan         Plan        `json:"plan"`
	Path         string      `json:"path"`
	ResponseID   pgtype.Int8 `json:"response_id"`
	ResponseTime pgtype.Int4 `json:"response_time"`
	Content      pgtype.Text `json:"content"`
	ContentType  string      `json:"content_type"`
	Method       HttpMethod  `json:"method"`
	// IPv4
	SourceIp     string             `json:"source_ip"`
	ContentSize  int32              `json:"content_size"`
	ResponseCode pgtype.Int4        `json:"response_code"`
	Headers      []byte             `json:"headers"`
	FormData     []byte             `json:"form_data"`
	QueryParams  []byte             `json:"query_params"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
	IsDeleted    pgtype.Bool        `json:"is_deleted"`
}

type Response

type Response struct {
	ID           int64              `json:"id"`
	UserID       pgtype.Int8        `json:"user_id"`
	EndpointID   int64              `json:"endpoint_id"`
	ResponseCode int32              `json:"response_code"`
	Content      pgtype.Text        `json:"content"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	IsDeleted    pgtype.Bool        `json:"is_deleted"`
}

type User

type User struct {
	ID        int64              `json:"id"`
	Name      string             `json:"name"`
	AvatarUrl string             `json:"avatar_url"`
	Username  string             `json:"username"`
	Plan      Plan               `json:"plan"`
	Email     string             `json:"email"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	IsDeleted pgtype.Bool        `json:"is_deleted"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL