librarian

package
v0.0.0-...-f99326c Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "librarian"

ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.

Variables

View Source
var MethodNames = [5]string{"get-book", "get-books", "create-book", "update-book", "delete-book"}

MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.

Functions

func MakeBadRequest

func MakeBadRequest(err error) *goa.ServiceError

MakeBadRequest builds a goa.ServiceError from an error.

func MakeInternalServerError

func MakeInternalServerError(err error) *goa.ServiceError

MakeInternalServerError builds a goa.ServiceError from an error.

func MakeNotFound

func MakeNotFound(err error) *goa.ServiceError

MakeNotFound builds a goa.ServiceError from an error.

func NewCreateBookEndpoint

func NewCreateBookEndpoint(s Service) goa.Endpoint

NewCreateBookEndpoint returns an endpoint function that calls the method "create-book" of service "librarian".

func NewDeleteBookEndpoint

func NewDeleteBookEndpoint(s Service) goa.Endpoint

NewDeleteBookEndpoint returns an endpoint function that calls the method "delete-book" of service "librarian".

func NewGetBookEndpoint

func NewGetBookEndpoint(s Service) goa.Endpoint

NewGetBookEndpoint returns an endpoint function that calls the method "get-book" of service "librarian".

func NewGetBooksEndpoint

func NewGetBooksEndpoint(s Service) goa.Endpoint

NewGetBooksEndpoint returns an endpoint function that calls the method "get-books" of service "librarian".

func NewUpdateBookEndpoint

func NewUpdateBookEndpoint(s Service) goa.Endpoint

NewUpdateBookEndpoint returns an endpoint function that calls the method "update-book" of service "librarian".

func NewViewedCreatebookresponse

func NewViewedCreatebookresponse(res *Createbookresponse, view string) *librarianviews.Createbookresponse

NewViewedCreatebookresponse initializes viewed result type Createbookresponse from result type Createbookresponse using the given view.

func NewViewedGetbookresponse

func NewViewedGetbookresponse(res *Getbookresponse, view string) *librarianviews.Getbookresponse

NewViewedGetbookresponse initializes viewed result type Getbookresponse from result type Getbookresponse using the given view.

func NewViewedGetbooksresponse

func NewViewedGetbooksresponse(res *Getbooksresponse, view string) *librarianviews.Getbooksresponse

NewViewedGetbooksresponse initializes viewed result type Getbooksresponse from result type Getbooksresponse using the given view.

func NewViewedUpdatebookresponse

func NewViewedUpdatebookresponse(res *Updatebookresponse, view string) *librarianviews.Updatebookresponse

NewViewedUpdatebookresponse initializes viewed result type Updatebookresponse from result type Updatebookresponse using the given view.

Types

type Client

type Client struct {
	GetBookEndpoint    goa.Endpoint
	GetBooksEndpoint   goa.Endpoint
	CreateBookEndpoint goa.Endpoint
	UpdateBookEndpoint goa.Endpoint
	DeleteBookEndpoint goa.Endpoint
}

Client is the "librarian" service client.

func NewClient

func NewClient(getBook, getBooks, createBook, updateBook, deleteBook goa.Endpoint) *Client

NewClient initializes a "librarian" service client given the endpoints.

func (*Client) CreateBook

func (c *Client) CreateBook(ctx context.Context, p *CreateBookPayload) (res *Createbookresponse, err error)

CreateBook calls the "create-book" endpoint of the "librarian" service. CreateBook may return the following errors:

  • "internal_server_error" (type *goa.ServiceError): Something went wrong on our end.
  • "bad_request" (type *goa.ServiceError): Bad request.
  • "not_found" (type *goa.ServiceError): Book not found.
  • error: internal error

func (*Client) DeleteBook

func (c *Client) DeleteBook(ctx context.Context, p *DeleteBookPayload) (err error)

DeleteBook calls the "delete-book" endpoint of the "librarian" service. DeleteBook may return the following errors:

  • "internal_server_error" (type *goa.ServiceError): Something went wrong on our end.
  • "bad_request" (type *goa.ServiceError): Bad request.
  • "not_found" (type *goa.ServiceError): Book not found.
  • error: internal error

func (*Client) GetBook

func (c *Client) GetBook(ctx context.Context, p *GetBookPayload) (res *Getbookresponse, err error)

GetBook calls the "get-book" endpoint of the "librarian" service. GetBook may return the following errors:

  • "internal_server_error" (type *goa.ServiceError): Something went wrong on our end.
  • "bad_request" (type *goa.ServiceError): Bad request.
  • "not_found" (type *goa.ServiceError): Book not found.
  • error: internal error

func (*Client) GetBooks

func (c *Client) GetBooks(ctx context.Context, p *GetBooksPayload) (res *Getbooksresponse, err error)

GetBooks calls the "get-books" endpoint of the "librarian" service. GetBooks may return the following errors:

  • "internal_server_error" (type *goa.ServiceError): Something went wrong on our end.
  • "bad_request" (type *goa.ServiceError): Bad request.
  • "not_found" (type *goa.ServiceError): Book not found.
  • error: internal error

func (*Client) UpdateBook

func (c *Client) UpdateBook(ctx context.Context, p *UpdateBookPayload) (res *Updatebookresponse, err error)

UpdateBook calls the "update-book" endpoint of the "librarian" service. UpdateBook may return the following errors:

  • "internal_server_error" (type *goa.ServiceError): Something went wrong on our end.
  • "bad_request" (type *goa.ServiceError): Bad request.
  • "not_found" (type *goa.ServiceError): Book not found.
  • error: internal error

type CreateBookPayload

type CreateBookPayload struct {
	// The title of the book.
	Title string
	// The author of the book.
	Author string
	// The URL to the cover image.
	BookCover string
	// The date at which the book was published.
	PublishedAt string
}

CreateBookPayload is the payload type of the librarian service create-book method.

type Createbookresponse

type Createbookresponse struct {
	// The unique id of the book.
	ID int
	// The title of the book.
	Title string
	// The author of the book.
	Author string
	// The cover image of the book.
	BookCover string
	// The date at which the book was published.
	PublishedAt string
}

Createbookresponse is the result type of the librarian service create-book method.

func NewCreatebookresponse

func NewCreatebookresponse(vres *librarianviews.Createbookresponse) *Createbookresponse

NewCreatebookresponse initializes result type Createbookresponse from viewed result type Createbookresponse.

type DeleteBookPayload

type DeleteBookPayload struct {
	// Book id
	ID int
}

DeleteBookPayload is the payload type of the librarian service delete-book method.

type Endpoints

type Endpoints struct {
	GetBook    goa.Endpoint
	GetBooks   goa.Endpoint
	CreateBook goa.Endpoint
	UpdateBook goa.Endpoint
	DeleteBook goa.Endpoint
}

Endpoints wraps the "librarian" service endpoints.

func NewEndpoints

func NewEndpoints(s Service) *Endpoints

NewEndpoints wraps the methods of the "librarian" service with endpoints.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "librarian" service endpoints.

type GetBookPayload

type GetBookPayload struct {
	// The ID of the book.
	ID int
}

GetBookPayload is the payload type of the librarian service get-book method.

type GetBooksPayload

type GetBooksPayload struct {
	// The numbers of records to skip before return.
	Skip int
	// The numbers of records to return.
	Take int
}

GetBooksPayload is the payload type of the librarian service get-books method.

type Getbookresponse

type Getbookresponse struct {
	// The unique id of the book.
	ID int
	// The title of the book.
	Title string
	// The author of the book.
	Author string
	// The cover image of the book.
	BookCover string
	// The date at which the book was published.
	PublishedAt string
}

Getbookresponse is the result type of the librarian service get-book method.

func NewGetbookresponse

func NewGetbookresponse(vres *librarianviews.Getbookresponse) *Getbookresponse

NewGetbookresponse initializes result type Getbookresponse from viewed result type Getbookresponse.

type Getbooksresponse

type Getbooksresponse struct {
	// List of paginated books.
	Books ResultbookCollection
}

Getbooksresponse is the result type of the librarian service get-books method.

func NewGetbooksresponse

func NewGetbooksresponse(vres *librarianviews.Getbooksresponse) *Getbooksresponse

NewGetbooksresponse initializes result type Getbooksresponse from viewed result type Getbooksresponse.

type Resultbook

type Resultbook struct {
	// The unique id of the book.
	ID int
	// The title of the book.
	Title string
	// The author of the book.
	Author string
	// The cover image of the book.
	BookCover string
	// The date at which the book was published.
	PublishedAt string
}

type ResultbookCollection

type ResultbookCollection []*Resultbook

type Service

type Service interface {
	// Retrieve a book by id.
	GetBook(context.Context, *GetBookPayload) (res *Getbookresponse, err error)
	// Get paginated books by specifying the number of books to skip and take.
	GetBooks(context.Context, *GetBooksPayload) (res *Getbooksresponse, err error)
	// Create a single book.
	CreateBook(context.Context, *CreateBookPayload) (res *Createbookresponse, err error)
	// Updates a book by the given id.
	UpdateBook(context.Context, *UpdateBookPayload) (res *Updatebookresponse, err error)
	// Delete a single book.
	DeleteBook(context.Context, *DeleteBookPayload) (err error)
}

The books service performs CRUD operations on books.

type UpdateBookPayload

type UpdateBookPayload struct {
	// The unique id of the book.
	ID *int
	// The title of the book.
	Title string
	// The author of the book.
	Author string
	// The URL to the cover image.
	BookCover string
	// The date at which the book was published.
	PublishedAt string
}

UpdateBookPayload is the payload type of the librarian service update-book method.

type Updatebookresponse

type Updatebookresponse struct {
	// The unique id of the book.
	ID int
	// The title of the book.
	Title string
	// The author of the book.
	Author string
	// The cover image of the book.
	BookCover string
	// The date at which the book was published.
	PublishedAt string
}

Updatebookresponse is the result type of the librarian service update-book method.

func NewUpdatebookresponse

func NewUpdatebookresponse(vres *librarianviews.Updatebookresponse) *Updatebookresponse

NewUpdatebookresponse initializes result type Updatebookresponse from viewed result type Updatebookresponse.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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