omdb

package module
v0.0.0-...-648d2cf Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 8 Imported by: 0

README

omdb

A Go package for interacting with the REST API of The Open Movie Database.

This API client is autogenerated from the OpenAPI specification, which can be found here.

Technical notes

The OpenAPI specification is converted from the original OAS 2.0 format to 3.0.1 using converter.swagger.io before it's used for generation.

Updating

The API client can be re-generated with the go generate command.

A curl installation is needed.

Licensing

This library is licensed under the MIT License, but the OpenAPI specification is licensed under the Creative Commons Attribution-NonCommercial 4.0 International license.

Documentation

Overview

Package omdb provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Package omdb provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT.

Index

Constants

View Source
const (
	APIKeyQueryParamScopes = "APIKeyQueryParam.Scopes"
)
View Source
const DefaultServerBaseURL = "https://www.omdbapi.com/"

DefaultServerBaseURL is the default OMDB API base URL.

Variables

This section is empty.

Functions

func NewGetIdRequest

func NewGetIdRequest(server string, params *GetIdParams) (*http.Request, error)

NewGetIdRequest generates requests for GetId

func NewGetTitleRequest

func NewGetTitleRequest(server string, params *GetTitleParams) (*http.Request, error)

NewGetTitleRequest generates requests for GetTitle

func NewTitleSearchRequest

func NewTitleSearchRequest(server string, params *TitleSearchParams) (*http.Request, error)

NewTitleSearchRequest generates requests for TitleSearch

func ParseBody

func ParseBody(b []byte) (map[string]interface{}, error)

ParseBody parses JSON bytes into an untyped map.

Types

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func NewDefaultClient

func NewDefaultClient(token string, opts ...ClientOption) (*Client, error)

NewDefaultClient creates a new Client with the DefaultServerBaseURL base URL and a WithToken ClientOption.

func (*Client) GetId

func (c *Client) GetId(ctx context.Context, params *GetIdParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) GetTitle

func (c *Client) GetTitle(ctx context.Context, params *GetTitleParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) TitleSearch

func (c *Client) TitleSearch(ctx context.Context, params *TitleSearchParams, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// GetId request
	GetId(ctx context.Context, params *GetIdParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// TitleSearch request
	TitleSearch(ctx context.Context, params *TitleSearchParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// GetTitle request
	GetTitle(ctx context.Context, params *GetTitleParams, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

func WithToken

func WithToken(token string) ClientOption

WithToken authenticates the client's requests with an `apikey` query parameter.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) GetIdWithResponse

func (c *ClientWithResponses) GetIdWithResponse(ctx context.Context, params *GetIdParams, reqEditors ...RequestEditorFn) (*GetIdResponse, error)

GetIdWithResponse request returning *GetIdResponse

func (*ClientWithResponses) GetTitleWithResponse

func (c *ClientWithResponses) GetTitleWithResponse(ctx context.Context, params *GetTitleParams, reqEditors ...RequestEditorFn) (*GetTitleResponse, error)

GetTitleWithResponse request returning *GetTitleResponse

func (*ClientWithResponses) TitleSearchWithResponse

func (c *ClientWithResponses) TitleSearchWithResponse(ctx context.Context, params *TitleSearchParams, reqEditors ...RequestEditorFn) (*TitleSearchResponse, error)

TitleSearchWithResponse request returning *TitleSearchResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// GetIdWithResponse request
	GetIdWithResponse(ctx context.Context, params *GetIdParams, reqEditors ...RequestEditorFn) (*GetIdResponse, error)

	// TitleSearchWithResponse request
	TitleSearchWithResponse(ctx context.Context, params *TitleSearchParams, reqEditors ...RequestEditorFn) (*TitleSearchResponse, error)

	// GetTitleWithResponse request
	GetTitleWithResponse(ctx context.Context, params *GetTitleParams, reqEditors ...RequestEditorFn) (*GetTitleResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type GetIdParams

type GetIdParams struct {
	// I A valid IMDb ID (e.g. tt0000001)
	I string `form:"i" json:"i"`

	// Plot Return short or full plot
	Plot *GetIdParamsPlot `form:"plot,omitempty" json:"plot,omitempty"`

	// R The response type to return
	R *GetIdParamsR `form:"r,omitempty" json:"r,omitempty"`

	// Callback JSONP callback name
	Callback *string `form:"callback,omitempty" json:"callback,omitempty"`
}

GetIdParams defines parameters for GetId.

type GetIdParamsPlot

type GetIdParamsPlot string

GetIdParamsPlot defines parameters for GetId.

const (
	GetIdParamsPlotFull  GetIdParamsPlot = "full"
	GetIdParamsPlotShort GetIdParamsPlot = "short"
)

Defines values for GetIdParamsPlot.

type GetIdParamsR

type GetIdParamsR string

GetIdParamsR defines parameters for GetId.

const (
	GetIdParamsRJson GetIdParamsR = "json"
	GetIdParamsRXml  GetIdParamsR = "xml"
)

Defines values for GetIdParamsR.

type GetIdResponse

type GetIdResponse struct {
	Body         []byte
	HTTPResponse *http.Response
}

func ParseGetIdResponse

func ParseGetIdResponse(rsp *http.Response) (*GetIdResponse, error)

ParseGetIdResponse parses an HTTP response from a GetIdWithResponse call

func (GetIdResponse) Status

func (r GetIdResponse) Status() string

Status returns HTTPResponse.Status

func (GetIdResponse) StatusCode

func (r GetIdResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type GetTitleParams

type GetTitleParams struct {
	// T Title of movie or series
	T string `form:"t" json:"t"`

	// Y Year of release
	Y *int `form:"y,omitempty" json:"y,omitempty"`

	// Type Return movie or series
	Type *GetTitleParamsType `form:"type,omitempty" json:"type,omitempty"`

	// Plot Return short or full plot
	Plot *GetTitleParamsPlot `form:"plot,omitempty" json:"plot,omitempty"`

	// R The response type to return
	R *GetTitleParamsR `form:"r,omitempty" json:"r,omitempty"`

	// Callback JSONP callback name
	Callback *string `form:"callback,omitempty" json:"callback,omitempty"`
}

GetTitleParams defines parameters for GetTitle.

type GetTitleParamsPlot

type GetTitleParamsPlot string

GetTitleParamsPlot defines parameters for GetTitle.

const (
	GetTitleParamsPlotFull  GetTitleParamsPlot = "full"
	GetTitleParamsPlotShort GetTitleParamsPlot = "short"
)

Defines values for GetTitleParamsPlot.

type GetTitleParamsR

type GetTitleParamsR string

GetTitleParamsR defines parameters for GetTitle.

const (
	Json GetTitleParamsR = "json"
	Xml  GetTitleParamsR = "xml"
)

Defines values for GetTitleParamsR.

type GetTitleParamsType

type GetTitleParamsType string

GetTitleParamsType defines parameters for GetTitle.

const (
	GetTitleParamsTypeMovie  GetTitleParamsType = "movie"
	GetTitleParamsTypeSeries GetTitleParamsType = "series"
)

Defines values for GetTitleParamsType.

type GetTitleResponse

type GetTitleResponse struct {
	Body         []byte
	HTTPResponse *http.Response
}

func ParseGetTitleResponse

func ParseGetTitleResponse(rsp *http.Response) (*GetTitleResponse, error)

ParseGetTitleResponse parses an HTTP response from a GetTitleWithResponse call

func (GetTitleResponse) Status

func (r GetTitleResponse) Status() string

Status returns HTTPResponse.Status

func (GetTitleResponse) StatusCode

func (r GetTitleResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type Response

type Response interface {
	// Status returns the status text.
	Status() string
	// StatusCode returns the status code.
	StatusCode() int
}

Response is an abstraction of a typed http.Response wrapper.

type TitleSearchParams

type TitleSearchParams struct {
	// S Title of movie or series
	S string `form:"s" json:"s"`

	// Y Year of release
	Y *int `form:"y,omitempty" json:"y,omitempty"`

	// Type Return movie or series
	Type *TitleSearchParamsType `form:"type,omitempty" json:"type,omitempty"`

	// R The response type to return
	R *TitleSearchParamsR `form:"r,omitempty" json:"r,omitempty"`

	// Page Page number to return
	Page *int `form:"page,omitempty" json:"page,omitempty"`

	// Callback JSONP callback name
	Callback *string `form:"callback,omitempty" json:"callback,omitempty"`
}

TitleSearchParams defines parameters for TitleSearch.

type TitleSearchParamsR

type TitleSearchParamsR string

TitleSearchParamsR defines parameters for TitleSearch.

const (
	TitleSearchParamsRJson TitleSearchParamsR = "json"
	TitleSearchParamsRXml  TitleSearchParamsR = "xml"
)

Defines values for TitleSearchParamsR.

type TitleSearchParamsType

type TitleSearchParamsType string

TitleSearchParamsType defines parameters for TitleSearch.

const (
	TitleSearchParamsTypeMovie  TitleSearchParamsType = "movie"
	TitleSearchParamsTypeSeries TitleSearchParamsType = "series"
)

Defines values for TitleSearchParamsType.

type TitleSearchResponse

type TitleSearchResponse struct {
	Body         []byte
	HTTPResponse *http.Response
}

func ParseTitleSearchResponse

func ParseTitleSearchResponse(rsp *http.Response) (*TitleSearchResponse, error)

ParseTitleSearchResponse parses an HTTP response from a TitleSearchWithResponse call

func (TitleSearchResponse) Status

func (r TitleSearchResponse) Status() string

Status returns HTTPResponse.Status

func (TitleSearchResponse) StatusCode

func (r TitleSearchResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

Jump to

Keyboard shortcuts

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