api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotAllowed

func NotAllowed(c *gin.Context)

NotAllowed returns a JSON 405 response for the API.

func NotFound

func NotFound(c *gin.Context)

NotFound returns a JSON response for the API. NOTE: we know it's weird to put server-side handlers like NotFound and NotAllowed here in the client/api side package but it unifies where we keep our error handling mechanisms.

Types

type APIv1

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

APIv1 implements the TenantClient interface

func (*APIv1) AppCreate

func (s *APIv1) AppCreate(ctx context.Context, in *App) (out *App, err error)

func (*APIv1) AppDelete

func (s *APIv1) AppDelete(ctx context.Context, id string) (err error)

func (*APIv1) AppDetail

func (s *APIv1) AppDetail(ctx context.Context, id string) (out *App, err error)

func (*APIv1) AppList

func (s *APIv1) AppList(ctx context.Context, in *AppQuery) (out *AppPage, err error)

func (*APIv1) Do

func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)

Do executes an http request against the server, performs error checking, and deserializes response data into the specified struct.

func (*APIv1) NewRequest

func (s *APIv1) NewRequest(ctx context.Context, method, path string, data interface{}, params *url.Values) (req *http.Request, err error)

func (*APIv1) SignUp

func (s *APIv1) SignUp(ctx context.Context, in *ContactInfo) (err error)

func (*APIv1) Status

func (s *APIv1) Status(ctx context.Context) (out *StatusReply, err error)

func (*APIv1) TopicCreate

func (s *APIv1) TopicCreate(ctx context.Context, in *Topic) (out *Topic, err error)

func (*APIv1) TopicDelete

func (s *APIv1) TopicDelete(ctx context.Context, id string) (err error)

func (*APIv1) TopicDetail

func (s *APIv1) TopicDetail(ctx context.Context, id string) (out *Topic, err error)

func (*APIv1) TopicList

func (s *APIv1) TopicList(ctx context.Context, in *TopicQuery) (out *TopicPage, err error)

func (*APIv1) UserCreate

func (s *APIv1) UserCreate(ctx context.Context, in *User) (out *User, err error)

func (*APIv1) UserDelete

func (s *APIv1) UserDelete(ctx context.Context, id string) (err error)

func (*APIv1) UserDetail

func (s *APIv1) UserDetail(ctx context.Context, id string) (out *User, err error)

func (*APIv1) UserList

func (s *APIv1) UserList(ctx context.Context, in *UserQuery) (out *UserPage, err error)

func (*APIv1) UserUpdate

func (s *APIv1) UserUpdate(ctx context.Context, in *User) (out *User, err error)

type App

type App struct {
	ID      string `json:"id" uri:"id" binding:"required"`
	AppName string `json:"app_name"`
}

type AppPage

type AppPage struct {
	Apps          []*App
	PrevPageToken string
	NextPageToken string
}

type AppQuery

type AppQuery struct {
	Query         string
	NextPageToken string
}

type ClientOption

type ClientOption func(c *APIv1) error

ClientOptions allows us to configure the APIv1 client when it is created.

func WithClient

func WithClient(client *http.Client) ClientOption

type ContactInfo

type ContactInfo struct {
	FirstName    string `json:"firstName"`
	LastName     string `json:"lastName"`
	Email        string `json:"email"`
	Country      string `json:"country"`
	Title        string `json:"title"`
	Organization string `json:"organization"`
}

ContactInfo allows users to sign up for email notifications from SendGrid and is specifically used to allow users to request Ensign Private Beta access.

type Reply

type Reply struct {
	Success bool   `json:"success"`
	Error   string `json:"error,omitempty"`
}

Reply contains standard fields that are used for generic API responses and errors.

func ErrorResponse

func ErrorResponse(err interface{}) Reply

Constructs a new response for an error or returns unsuccessful.

type StatusReply

type StatusReply struct {
	Status  string `json:"status"`
	Uptime  string `json:"uptime,omitempty"`
	Version string `json:"version,omitempty"`
}

Returned on status requests.

type TenantClient

type TenantClient interface {
	Status(context.Context) (*StatusReply, error)
	SignUp(context.Context, *ContactInfo) error

	UserList(context.Context, *UserQuery) (*UserPage, error)
	UserCreate(context.Context, *User) (*User, error)
	UserDetail(ctx context.Context, id string) (*User, error)
	UserUpdate(context.Context, *User) (*User, error)
	UserDelete(ctx context.Context, id string) error

	AppList(context.Context, *AppQuery) (*AppPage, error)
	AppCreate(context.Context, *App) (*App, error)
	AppDetail(ctx context.Context, id string) (*App, error)
	AppDelete(ctx context.Context, id string) error

	TopicList(context.Context, *TopicQuery) (*TopicPage, error)
	TopicCreate(context.Context, *Topic) (*Topic, error)
	TopicDetail(ctx context.Context, id string) (*Topic, error)
	TopicDelete(ctx context.Context, id string) error
}

func New

func New(endpoint string, opts ...ClientOption) (_ TenantClient, err error)

New creates a new API v1 client that implements the Tenant Client interface.

type Topic

type Topic struct {
	ID        string `json:"id" uri:"id" binding:"required"`
	TopicName string `json:"topic_name"`
}

type TopicPage

type TopicPage struct {
	Topics        []*Topic
	PrevPageToken string
	NextPageToken string
}

type TopicQuery

type TopicQuery struct {
	Query         string
	NextPageToken string
}

type User

type User struct {
	ID       string `json:"id" uri:"id" binding:"required"`
	UserName string `json:"user_name"`
}

type UserPage

type UserPage struct {
	Users         []*User
	PrevPageToken string
	NextPageToken string
}

type UserQuery

type UserQuery struct {
	Query         string
	NextPageToken string
}

Jump to

Keyboard shortcuts

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