petstoreapi

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Hostname = "petstore.example"

Hostname is the default hostname of the microservice.

Variables

View Source
var (
	// HINT: Insert endpoint definitions here
	AddPet     = Def{Method: "POST", Route: "/pet"}                     // MARKER: AddPet
	GetPetById = Def{Method: "GET", Route: "/pet/{petId}"}              // MARKER: GetPetById
	UploadFile = Def{Method: "POST", Route: "/pet/{petId}/uploadImage"} // MARKER: UploadFile
)

Functions

This section is empty.

Types

type AddPetIn

type AddPetIn struct {
	HTTPRequestBody *Pet `json:"-"`
}

AddPetIn are the input arguments of AddPet.

type AddPetOut

type AddPetOut struct {
	HTTPResponseBody *Pet `json:"-"`
	HTTPStatusCode   int  `json:"-"`
}

AddPetOut are the output arguments of AddPet.

type AddPetResponse

type AddPetResponse multicastResponse // MARKER: AddPet

AddPetResponse packs the response of AddPet.

func (*AddPetResponse) Get

func (_res *AddPetResponse) Get() (httpResponseBody *Pet, httpStatusCode int, err error)

Get unpacks the return arguments of AddPet.

type ApiResponse

type ApiResponse struct {
	Code    int32  `json:"code,omitzero" jsonschema:"description=Code is the response code"`
	Type    string `json:"type,omitzero" jsonschema:"description=Type is the response type"`
	Message string `json:"message,omitzero" jsonschema:"description=Message is the response message"`
}

ApiResponse is a generic response from the Swagger Petstore API. Imported from the Swagger Petstore API.

type Category

type Category struct {
	ID   int64  `json:"id,omitzero" jsonschema:"description=ID is the category identifier"`
	Name string `json:"name,omitzero" jsonschema:"description=Name is the category name"`
}

Category is a pet category. Imported from the Swagger Petstore API.

type Client

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

Client is a lightweight proxy for making unicast calls to the microservice.

func NewClient

func NewClient(caller service.Publisher) Client

NewClient creates a new unicast client proxy to the microservice.

func (Client) AddPet

func (_c Client) AddPet(ctx context.Context, httpRequestBody *Pet) (httpResponseBody *Pet, httpStatusCode int, err error)

AddPet adds a new pet to the store.

Input:

  • httpRequestBody: httpRequestBody is the pet to add

Output:

  • httpResponseBody: httpResponseBody is the created pet
  • httpStatusCode: httpStatusCode is the remote HTTP status code

func (Client) ForHost

func (_c Client) ForHost(host string) Client

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (Client) GetPetById

func (_c Client) GetPetById(ctx context.Context, petId int64) (httpResponseBody *Pet, httpStatusCode int, err error)

GetPetById returns a single pet.

Input:

  • petId: petId is the ID of the pet to return

Output:

  • httpResponseBody: httpResponseBody is the requested pet
  • httpStatusCode: httpStatusCode is the remote HTTP status code

func (Client) UploadFile

func (_c Client) UploadFile(ctx context.Context, relativeURL string, body any) (res *http.Response, err error)

UploadFile uploads an image of the pet.

If a URL is provided, it is resolved relative to the URL of the endpoint. If the body is of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON.

func (Client) WithOptions

func (_c Client) WithOptions(opts ...pub.Option) Client

WithOptions returns a copy of the client with options to be applied to requests.

type Def

type Def struct {
	Method string
	Route  string
}

Def is the routing identity of an endpoint exposed by this microservice.

func (Def) URL

func (d Def) URL() string

URL is the full URL of the endpoint, joined with the package-level Hostname.

type Executor

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

Executor runs tasks and workflows synchronously, blocking until termination. It is primarily intended for integration tests.

func NewExecutor

func NewExecutor(caller service.Publisher) Executor

NewExecutor creates a new executor proxy to the microservice.

func (Executor) ForHost

func (_c Executor) ForHost(host string) Executor

ForHost returns a copy of the executor with a different hostname to be applied to requests.

func (Executor) WithFlowOptions

func (_c Executor) WithFlowOptions(flowOptions *workflow.FlowOptions) Executor

WithFlowOptions returns a copy of the executor that creates workflows with the given flow options (priority, fairness key and weight). It has no effect on task execution.

func (Executor) WithInputFlow

func (_c Executor) WithInputFlow(flow *workflow.Flow) Executor

WithInputFlow returns a copy of the executor with an input flow to use for task execution. The input flow's state is available to the task in addition to the typed input arguments.

func (Executor) WithOptions

func (_c Executor) WithOptions(opts ...pub.Option) Executor

WithOptions returns a copy of the executor with options to be applied to requests.

func (Executor) WithOutputFlow

func (_c Executor) WithOutputFlow(flow *workflow.Flow) Executor

WithOutputFlow returns a copy of the executor with an output flow to populate after task execution. The output flow captures the full flow state including control signals (Goto, Retry, Interrupt, Sleep).

func (Executor) WithWorkflowRunner

func (_c Executor) WithWorkflowRunner(runner WorkflowRunner) Executor

WithWorkflowRunner returns a copy of the executor with a workflow runner for executing workflows. foremanapi.NewClient(svc) satisfies the WorkflowRunner interface.

type GetPetByIdIn

type GetPetByIdIn struct {
	PetId int64 `json:"petId,omitzero"`
}

GetPetByIdIn are the input arguments of GetPetById.

type GetPetByIdOut

type GetPetByIdOut struct {
	HTTPResponseBody *Pet `json:"-"`
	HTTPStatusCode   int  `json:"-"`
}

GetPetByIdOut are the output arguments of GetPetById.

type GetPetByIdResponse

type GetPetByIdResponse multicastResponse // MARKER: GetPetById

GetPetByIdResponse packs the response of GetPetById.

func (*GetPetByIdResponse) Get

func (_res *GetPetByIdResponse) Get() (httpResponseBody *Pet, httpStatusCode int, err error)

Get unpacks the return arguments of GetPetById.

type Hook

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

Hook assists in the subscription to the events of the microservice.

func NewHook

func NewHook(listener service.Subscriber) Hook

NewHook creates a new hook to the events of the microservice.

func (Hook) ForHost

func (c Hook) ForHost(host string) Hook

ForHost returns a copy of the hook with a different hostname to be applied to the subscription.

func (Hook) WithOptions

func (c Hook) WithOptions(opts ...sub.Option) Hook

WithOptions returns a copy of the hook with options to be applied to subscriptions.

type MulticastClient

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

MulticastClient is a lightweight proxy for making multicast calls to the microservice.

func NewMulticastClient

func NewMulticastClient(caller service.Publisher) MulticastClient

NewMulticastClient creates a new multicast client proxy to the microservice.

func (MulticastClient) AddPet

func (_c MulticastClient) AddPet(ctx context.Context, httpRequestBody *Pet) iter.Seq[*AddPetResponse]

AddPet adds a new pet to the store.

Input:

  • httpRequestBody: httpRequestBody is the pet to add

Output:

  • httpResponseBody: httpResponseBody is the created pet
  • httpStatusCode: httpStatusCode is the remote HTTP status code

func (MulticastClient) ForHost

func (_c MulticastClient) ForHost(host string) MulticastClient

ForHost returns a copy of the client with a different hostname to be applied to requests.

func (MulticastClient) GetPetById

func (_c MulticastClient) GetPetById(ctx context.Context, petId int64) iter.Seq[*GetPetByIdResponse]

GetPetById returns a single pet.

Input:

  • petId: petId is the ID of the pet to return

Output:

  • httpResponseBody: httpResponseBody is the requested pet
  • httpStatusCode: httpStatusCode is the remote HTTP status code

func (MulticastClient) UploadFile

func (_c MulticastClient) UploadFile(ctx context.Context, relativeURL string, body any) iter.Seq[*pub.Response]

UploadFile uploads an image of the pet.

If a URL is provided, it is resolved relative to the URL of the endpoint. If the body is of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON.

func (MulticastClient) WithOptions

func (_c MulticastClient) WithOptions(opts ...pub.Option) MulticastClient

WithOptions returns a copy of the client with options to be applied to requests.

type MulticastTrigger

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

MulticastTrigger is a lightweight proxy for triggering the events of the microservice.

func NewMulticastTrigger

func NewMulticastTrigger(caller service.Publisher) MulticastTrigger

NewMulticastTrigger creates a new multicast trigger of events of the microservice.

func (MulticastTrigger) ForHost

func (_c MulticastTrigger) ForHost(host string) MulticastTrigger

ForHost returns a copy of the trigger with a different hostname to be applied to requests.

func (MulticastTrigger) WithOptions

func (_c MulticastTrigger) WithOptions(opts ...pub.Option) MulticastTrigger

WithOptions returns a copy of the trigger with options to be applied to requests.

type Pet

type Pet struct {
	ID        int64     `json:"id,omitzero" jsonschema:"description=ID is the pet identifier"`
	Name      string    `json:"name,omitzero" jsonschema:"description=Name is the pet name"`
	Category  *Category `json:"category,omitzero" jsonschema:"description=Category is the pet category"`
	PhotoURLs []string  `json:"photoUrls,omitzero" jsonschema:"description=PhotoURLs are the URLs of the pet photos"`
	Tags      []Tag     `json:"tags,omitzero" jsonschema:"description=Tags are the pet tags"`
	Status    string    `json:"status,omitzero" jsonschema:"description=Status is the pet status in the store"`
}

Pet is a pet in the store. Imported from the Swagger Petstore API.

type Tag

type Tag struct {
	ID   int64  `json:"id,omitzero" jsonschema:"description=ID is the tag identifier"`
	Name string `json:"name,omitzero" jsonschema:"description=Name is the tag name"`
}

Tag is a pet tag. Imported from the Swagger Petstore API.

type WorkflowRunner

type WorkflowRunner interface {
	Run(ctx context.Context, workflowName string, initialState any, opts *workflow.FlowOptions) (outcome *workflow.FlowOutcome, err error)
}

WorkflowRunner executes a workflow by name with initial state, blocking until termination. foremanapi.Client satisfies this interface.

Jump to

Keyboard shortcuts

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