swaggerpetstore

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 11 Imported by: 0

README

Getting Started with Swagger Petstore

Introduction

This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.

Find out more about Swagger: http://swagger.io

Requirements

The SDK requires Go version 1.18 or above.

Installation

The following section explains how to use the swaggerpetstore library in a new project.

1. Install the Package

To use the package in your application, you can install the package from pkg.go.dev using the following command:

$ go get github.com/Syed-Subtain/GolangTest@v1.0.0

You can also view the package at: https://pkg.go.dev/github.com/Syed-Subtain/GolangTest@v1.0.0

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
environment Environment The API environment.
Default: Environment.PRODUCTION
httpConfiguration HttpConfiguration Configurable http client options like timeout and retries.
apiKeyCredentials ApiKeyCredentials The Credentials Setter for Custom Header Signature
petstoreAuthCredentials PetstoreAuthCredentials The Credentials Setter for OAuth 2 Implicit Grant

The API client can be initialized as follows:

client := swaggerpetstore.NewClient(
    swaggerpetstore.CreateConfiguration(
        swaggerpetstore.WithHttpConfiguration(
            swaggerpetstore.CreateHttpConfiguration(
                swaggerpetstore.WithTimeout(0),
            ),
        ),
        swaggerpetstore.WithEnvironment(swaggerpetstore.PRODUCTION),
        swaggerpetstore.WithApiKeyCredentials(
            swaggerpetstore.NewApiKeyCredentials("api_key"),
        ),
        swaggerpetstore.WithPetstoreAuthCredentials(
            swaggerpetstore.NewPetstoreAuthCredentials(
                "OAuthClientId",
                "OAuthRedirectUri",
            ).
                WithOAuthScopes([]models.OAuthScopePetstoreAuthEnum{models.OAuthScopePetstoreAuthEnum("read:pets"), models.OAuthScopePetstoreAuthEnum("write:pets")}),
        ),
    ),
)

Authorization

This API uses the following authentication schemes.

List of APIs

Classes Documentation

GolangTest

Documentation

Overview

Package swaggerpetstore

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).

Index

Constants

View Source
const UserAgent = "APIMATIC 3.0"

Variables

View Source
var NewAndAuth = https.NewAndAuth

NewAndAuth creates a new AndAuth.

View Source
var NewAuth = https.NewAuth

NewAuth creates a new Auth.

View Source
var NewHttpConfiguration = https.NewHttpConfiguration

NewHttpConfiguration creates a new HttpConfiguration.

View Source
var NewOrAuth = https.NewOrAuth

NewOrAuth creates a new OrAuth.

View Source
var NewRetryConfiguration = https.NewRetryConfiguration

NewRetryConfiguration creates a new RetryConfiguration.

View Source
var WithBackoffFactor = https.WithBackoffFactor

WithBackoffFactor sets the BackoffFactor.

View Source
var WithHttpMethodsToRetry = https.WithHttpMethodsToRetry

WithHttpMethodsToRetry sets the HttpMethodsToRetry.

View Source
var WithHttpStatusCodesToRetry = https.WithHttpStatusCodesToRetry

WithHttpStatusCodesToRetry sets the HttpStatusCodesToRetry.

View Source
var WithMaxRetryAttempts = https.WithMaxRetryAttempts

WithMaxRetryAttempts sets the MaxRetryAttempts.

View Source
var WithMaximumRetryWaitTime = https.WithMaximumRetryWaitTime

WithMaximumRetryWaitTime sets the MaximumRetryWaitTime.

View Source
var WithRetryConfiguration = https.WithRetryConfiguration

WithRetryConfiguration sets the RetryConfiguration.

View Source
var WithRetryInterval = https.WithRetryInterval

WithRetryInterval sets the RetryInterval.

View Source
var WithRetryOnTimeout = https.WithRetryOnTimeout

WithRetryOnTimeout sets the RetryOnTimeout.

View Source
var WithTimeout = https.WithTimeout

WithTimeout sets the Timeout.

View Source
var WithTransport = https.WithTransport

WithTransport sets the Transport.

Functions

func NewBaseController

func NewBaseController(cb callBuilderFactory) *baseController

NewBaseController creates a new instance of baseController. It takes a callBuilderFactory as a parameter and returns a pointer to the baseController.

Types

type ApiKeyCredentials

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

ApiKeyCredentials represents the credentials required for `api_key` authentication.

func NewApiKeyCredentials

func NewApiKeyCredentials(apiKey string) ApiKeyCredentials

NewApiKeyCredentials creates a new instance of ApiKeyCredentials with provided parameters.

func (ApiKeyCredentials) ApiKey

func (a ApiKeyCredentials) ApiKey() string

ApiKey returns the apiKey associated with the ApiKeyCredentials.

func (ApiKeyCredentials) Authenticator

func (a ApiKeyCredentials) Authenticator() https.HttpInterceptor

Authenticator function returns HttpInterceptor function that provides authentication for API calls.

func (ApiKeyCredentials) Validate

func (a ApiKeyCredentials) Validate() error

Validate function returns validation error associated with the ApiKeyCredentials.

func (ApiKeyCredentials) WithApiKey

func (a ApiKeyCredentials) WithApiKey(apiKey string) ApiKeyCredentials

WithApiKey sets apiKey in ApiKeyCredentials.

type ClientInterface

type ClientInterface interface {
	Configuration() Configuration
	CloneWithConfiguration(options ...ConfigurationOptions) ClientInterface
	PetController() *PetController
	StoreController() *StoreController
	UserController() *UserController
	PetstoreAuthManager() *PetstoreAuthManager
}

Client is an interface representing the main client for accessing configuration and controllers.

func NewClient

func NewClient(configuration Configuration) ClientInterface

NewClient is the constructor for creating a new client instance. It takes a Configuration object as a parameter and returns the Client interface.

type Configuration

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

Configuration holds configuration settings.

func CreateConfiguration

func CreateConfiguration(options ...ConfigurationOptions) Configuration

CreateConfiguration creates a new Configuration with the provided options.

func CreateConfigurationFromEnvironment

func CreateConfigurationFromEnvironment(options ...ConfigurationOptions) Configuration

CreateConfigurationFromEnvironment creates a new Configuration with default settings. It also configures various Configuration options.

func DefaultConfiguration

func DefaultConfiguration() Configuration

DefaultConfiguration returns the default Configuration.

func (Configuration) ApiKeyCredentials

func (c Configuration) ApiKeyCredentials() ApiKeyCredentials

ApiKeyCredentials returns the ApiKeyCredentials from the Configuration.

func (Configuration) Environment

func (c Configuration) Environment() Environment

Environment returns the Environment from the Configuration.

func (Configuration) HttpConfiguration

func (c Configuration) HttpConfiguration() HttpConfiguration

HttpConfiguration returns the HttpConfiguration from the Configuration.

func (Configuration) PetstoreAuthCredentials

func (c Configuration) PetstoreAuthCredentials() PetstoreAuthCredentials

PetstoreAuthCredentials returns the PetstoreAuthCredentials from the Configuration.

type ConfigurationOptions

type ConfigurationOptions func(*Configuration)

ConfigurationOptions represents a function type that can be used to apply options to the Configuration struct.

func WithApiKeyCredentials

func WithApiKeyCredentials(apiKeyCredentials ApiKeyCredentials) ConfigurationOptions

WithApiKeyCredentials is an option that sets the ApiKeyCredentials in the Configuration.

func WithEnvironment

func WithEnvironment(environment Environment) ConfigurationOptions

WithEnvironment is an option that sets the Environment in the Configuration.

func WithHttpConfiguration

func WithHttpConfiguration(httpConfiguration HttpConfiguration) ConfigurationOptions

WithHttpConfiguration is an option that sets the HttpConfiguration in the Configuration.

func WithPetstoreAuthCredentials

func WithPetstoreAuthCredentials(petstoreAuthCredentials PetstoreAuthCredentials) ConfigurationOptions

WithPetstoreAuthCredentials is an option that sets the PetstoreAuthCredentials in the Configuration.

type Environment

type Environment string

Environment represents available environments.

const (
	PRODUCTION Environment = "production"
)

type HttpConfiguration

type HttpConfiguration = https.HttpConfiguration

HttpConfiguration holds the configuration options for the client.

func CreateHttpConfiguration

func CreateHttpConfiguration(options ...HttpConfigurationOptions) HttpConfiguration

CreateHttpConfiguration creates a new HttpConfiguration with the provided options.

func DefaultHttpConfiguration

func DefaultHttpConfiguration() HttpConfiguration

DefaultHttpConfiguration returns the default HttpConfiguration for HTTP requests. It also configures various HttpConfiguration options.

type HttpConfigurationOptions

type HttpConfigurationOptions = https.HttpConfigurationOptions

HttpConfigurationOptions is a function type that modifies the HttpConfiguration.

type PetController

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

PetController represents a controller struct.

func NewPetController

func NewPetController(baseController baseController) *PetController

NewPetController creates a new instance of PetController. It takes a baseController as a parameter and returns a pointer to the PetController.

func (*PetController) AddPet

func (p *PetController) AddPet(
	ctx context.Context,
	body *models.Pet) (
	*http.Response,
	error)

AddPet takes context, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Add a new pet to the store

func (*PetController) DeletePet

func (p *PetController) DeletePet(
	ctx context.Context,
	petId int64,
	apiKey *string) (
	*http.Response,
	error)

DeletePet takes context, petId, apiKey as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Deletes a pet

func (*PetController) FindPetsByStatus

func (p *PetController) FindPetsByStatus(
	ctx context.Context,
	status []models.Status2Enum) (
	models.ApiResponse[[]models.Pet],
	error)

FindPetsByStatus takes context, status as parameters and returns an models.ApiResponse with []models.Pet data and an error if there was an issue with the request or response. Multiple status values can be provided with comma separated strings

func (*PetController) FindPetsByTags

func (p *PetController) FindPetsByTags(
	ctx context.Context,
	tags []string) (
	models.ApiResponse[[]models.Pet],
	error)

FindPetsByTags takes context, tags as parameters and returns an models.ApiResponse with []models.Pet data and an error if there was an issue with the request or response. Deprecated: findPetsByTags is deprecated Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

func (*PetController) GetPetById

func (p *PetController) GetPetById(
	ctx context.Context,
	petId int64) (
	models.ApiResponse[models.Pet],
	error)

GetPetById takes context, petId as parameters and returns an models.ApiResponse with models.Pet data and an error if there was an issue with the request or response. Returns a single pet

func (*PetController) UpdatePet

func (p *PetController) UpdatePet(
	ctx context.Context,
	body *models.Pet) (
	*http.Response,
	error)

UpdatePet takes context, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Update an existing pet

func (*PetController) UpdatePetWithForm

func (p *PetController) UpdatePetWithForm(
	ctx context.Context,
	petId int64,
	name *string,
	status *string) (
	*http.Response,
	error)

UpdatePetWithForm takes context, petId, name, status as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Updates a pet in the store with form data

func (*PetController) UploadFile

func (p *PetController) UploadFile(
	ctx context.Context,
	petId int64,
	additionalMetadata *string,
	file *models.FileWrapper) (
	models.ApiResponse[models.MApiResponse],
	error)

UploadFile takes context, petId, additionalMetadata, file as parameters and returns an models.ApiResponse with models.MApiResponse data and an error if there was an issue with the request or response. uploads an image

type PetstoreAuthCredentials

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

PetstoreAuthCredentials represents the credentials required for `petstore_auth` authentication.

func NewPetstoreAuthCredentials

func NewPetstoreAuthCredentials(
	oAuthClientId string,
	oAuthRedirectUri string) PetstoreAuthCredentials

NewPetstoreAuthCredentials creates a new instance of PetstoreAuthCredentials with provided parameters.

func (PetstoreAuthCredentials) Authenticator

func (p PetstoreAuthCredentials) Authenticator() https.HttpInterceptor

Authenticator function returns HttpInterceptor function that provides authentication for API calls.

func (PetstoreAuthCredentials) OAuthClientId

func (p PetstoreAuthCredentials) OAuthClientId() string

OAuthClientId returns the oAuthClientId associated with the PetstoreAuthCredentials.

func (PetstoreAuthCredentials) OAuthRedirectUri

func (p PetstoreAuthCredentials) OAuthRedirectUri() string

OAuthRedirectUri returns the oAuthRedirectUri associated with the PetstoreAuthCredentials.

func (PetstoreAuthCredentials) OAuthScopes

OAuthScopes returns the oAuthScopes associated with the PetstoreAuthCredentials.

func (PetstoreAuthCredentials) OAuthToken

func (p PetstoreAuthCredentials) OAuthToken() models.OAuthToken

OAuthToken returns the oAuthToken associated with the PetstoreAuthCredentials.

func (PetstoreAuthCredentials) Validate

func (p PetstoreAuthCredentials) Validate() error

Validate function returns validation error associated with the PetstoreAuthCredentials.

func (PetstoreAuthCredentials) WithOAuthClientId

func (p PetstoreAuthCredentials) WithOAuthClientId(oAuthClientId string) PetstoreAuthCredentials

WithOAuthClientId sets oAuthClientId in PetstoreAuthCredentials.

func (PetstoreAuthCredentials) WithOAuthRedirectUri

func (p PetstoreAuthCredentials) WithOAuthRedirectUri(oAuthRedirectUri string) PetstoreAuthCredentials

WithOAuthRedirectUri sets oAuthRedirectUri in PetstoreAuthCredentials.

func (PetstoreAuthCredentials) WithOAuthScopes

WithOAuthScopes sets oAuthScopes in PetstoreAuthCredentials.

func (PetstoreAuthCredentials) WithOAuthToken

WithOAuthToken sets oAuthToken in PetstoreAuthCredentials.

type PetstoreAuthManager

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

PetstoreAuthManager is a manager responsible for handling authorization related operations.

func (*PetstoreAuthManager) BuildAuthorizationUrl

func (p *PetstoreAuthManager) BuildAuthorizationUrl(state *string) string

BuildAuthorizationUrl checks the expiry of OAuth Token.

func (*PetstoreAuthManager) OAuthTokenIsExpired

func (p *PetstoreAuthManager) OAuthTokenIsExpired() bool

OAuthTokenIsExpired checks the expiry of OAuth Token.

type RetryConfiguration

type RetryConfiguration = https.RetryConfiguration

RetryConfiguration holds the configuration options for the client.

func CreateRetryConfiguration

func CreateRetryConfiguration(options ...RetryConfigurationOptions) RetryConfiguration

CreateRetryConfiguration creates a new RetryConfiguration with the provided options.

func DefaultRetryConfiguration

func DefaultRetryConfiguration() RetryConfiguration

DefaultRetryConfiguration returns the default RetryConfiguration for HTTP requests. It also configures various retry options.

type RetryConfigurationOptions

type RetryConfigurationOptions = https.RetryConfigurationOptions

RetryConfigurationOptions is a function type that modifies the RetryConfiguration.

type Server

type Server string

Server represents available servers.

const (
	SERVER1    Server = "server1"
	SERVER2    Server = "server2"
	AUTHSERVER Server = "auth server"
)

type StoreController

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

StoreController represents a controller struct.

func NewStoreController

func NewStoreController(baseController baseController) *StoreController

NewStoreController creates a new instance of StoreController. It takes a baseController as a parameter and returns a pointer to the StoreController.

func (*StoreController) DeleteOrder

func (s *StoreController) DeleteOrder(
	ctx context.Context,
	orderId int64) (
	*http.Response,
	error)

DeleteOrder takes context, orderId as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors

func (*StoreController) GetInventory

func (s *StoreController) GetInventory(ctx context.Context) (
	models.ApiResponse[map[string]int],
	error)

GetInventory takes context as parameters and returns an models.ApiResponse with map[string]int data and an error if there was an issue with the request or response. Returns a map of status codes to quantities

func (*StoreController) GetOrderById

func (s *StoreController) GetOrderById(
	ctx context.Context,
	orderId int64) (
	models.ApiResponse[models.Order],
	error)

GetOrderById takes context, orderId as parameters and returns an models.ApiResponse with models.Order data and an error if there was an issue with the request or response. For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions

func (*StoreController) PlaceOrder

func (s *StoreController) PlaceOrder(
	ctx context.Context,
	body *models.Order) (
	models.ApiResponse[models.Order],
	error)

PlaceOrder takes context, body as parameters and returns an models.ApiResponse with models.Order data and an error if there was an issue with the request or response. Place an order for a pet

type UserController

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

UserController represents a controller struct.

func NewUserController

func NewUserController(baseController baseController) *UserController

NewUserController creates a new instance of UserController. It takes a baseController as a parameter and returns a pointer to the UserController.

func (*UserController) CreateUser

func (u *UserController) CreateUser(
	ctx context.Context,
	body *models.User) (
	*http.Response,
	error)

CreateUser takes context, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This can only be done by the logged in user.

func (*UserController) CreateUsersWithArrayInput

func (u *UserController) CreateUsersWithArrayInput(
	ctx context.Context,
	body []models.User) (
	*http.Response,
	error)

CreateUsersWithArrayInput takes context, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Creates list of users with given input array

func (*UserController) CreateUsersWithListInput

func (u *UserController) CreateUsersWithListInput(
	ctx context.Context,
	body []models.User) (
	*http.Response,
	error)

CreateUsersWithListInput takes context, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Creates list of users with given input array

func (*UserController) DeleteUser

func (u *UserController) DeleteUser(
	ctx context.Context,
	username string) (
	*http.Response,
	error)

DeleteUser takes context, username as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This can only be done by the logged in user.

func (*UserController) GetUserByName

func (u *UserController) GetUserByName(
	ctx context.Context,
	username string) (
	models.ApiResponse[models.User],
	error)

GetUserByName takes context, username as parameters and returns an models.ApiResponse with models.User data and an error if there was an issue with the request or response. Get user by user name

func (*UserController) LoginUser

func (u *UserController) LoginUser(
	ctx context.Context,
	username string,
	password string) (
	models.ApiResponse[string],
	error)

LoginUser takes context, username, password as parameters and returns an models.ApiResponse with string data and an error if there was an issue with the request or response. Logs user into the system

func (*UserController) LogoutUser

func (u *UserController) LogoutUser(ctx context.Context) (
	*http.Response,
	error)

LogoutUser takes context as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. Logs out current logged in user session

func (*UserController) UpdateUser

func (u *UserController) UpdateUser(
	ctx context.Context,
	username string,
	body *models.User) (
	*http.Response,
	error)

UpdateUser takes context, username, body as parameters and returns an models.ApiResponse with data and an error if there was an issue with the request or response. This can only be done by the logged in user.

Directories

Path Synopsis
Package swaggerpetstore
Package swaggerpetstore
Package swaggerpetstore
Package swaggerpetstore

Jump to

Keyboard shortcuts

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