Categorygithub.com/jonasrmichel/radio-garden-go
modulepackage
0.1.0
Repository: https://github.com/jonasrmichel/radio-garden-go.git
Documentation: pkg.go.dev

# README

radio-garden-go

A Go client and command line application for the Radio Garden API.

The client is autogenerated by oapi-codegen from radio-garden-openapi, an unofficial Radio Garden OpenAPI specification.

Client library

This package includes two client variants:

  • Client returns raw HTTP responses.
  • ClientWithResponses is a wrapper around Client with response type handling.

Example

import (
	"context"
	"fmt"

	radiogarden "github.com/jonasrmichel/radio-garden-go"
)

func main() {
	// construct a client
	client, err := radiogarden.NewClientWithResponses("https://radio.garden/api")
	if err != nil {
		panic(err)
	}

	// get a radio station's details
	res, err := client.GetAraContentChannelChannelIdWithResponse(
		context.Background(),
		"9bd5454",
	)
	if err != nil {
		panic(err)
	}

	// print the station's details
	fmt.Printf("%+v", res.JSON200.Data)
}

Updating the client

The client implementation is generated by oapi-codegen. Any Radio Garden API changes will require that the client be updated.

Run the following commands to update the client:

# install oapi-codegen (see below)
$ go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen

# generate the client
$ go generate ./...

# install any missing dependencies
$ go mod tidy

Support for oneOf and anyOf schema types

Currently, oapi-codegen does not support the OpenAPI oneOf or anyOf keywords. That caveat is addressed by this pull request.

To update the client with support for oneOf and anyOf schema types, download and install that PR's fork manually:

# clone ispringtech's oapi-codegen fork
$ git clone -b union [email protected]:ispringtech/oapi-codegen.git

# go there
$ cd oapi-codegen

# install oapi-codegen
$ go install ./cmd/oapi-codegen

The client implementation in this project does include type level support for oneOf and anyOf schema types generated by the above fork.

Command line application

Run the following commands to install and run the radio-garden command line application:

# install the radio-garden cli app
$ go install github.com/jonasrmichel/radio-garden-go/radio-garden

# run the app
$ radio-garden -h
An application for using the Radio Garden API

Usage:
  radio-garden [command]

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  geo         Get your geolocation
  help        Help about any command
  place       Get a place's details
  places      Get places with registered radio stations
  search      Search for countries, places, and radio stations
  station     Get a radio station's details
  stations    Get a place's registered radio stations

Flags:
  -f, --format          format the output
  -h, --help            help for radio-garden
  -s, --server string   the Radio Garden server (default "https://radio.garden/api")

Use "radio-garden [command] --help" for more information about a command.

License

The client and CLI tool in this project are released under the Apache 2.0 License. Radio Garden and its API are copyrighted by Radio Garden BV.

# Packages

No description provided by the author

# Functions

CheckResponse returns a non-nil error if res StatusCode is not 200 or if err is non-nil.
EnsureStatus returns a non-nil error when the res Status is not status.
EnsureStatusByCode returns a non-nil error when the HTTP status text of res StatusCode does not match that of code.
EnsureStatusCode returns a non-nil error when the res StatusCode is not code.
GetSwagger returns the Swagger specification corresponding to the generated code in this file.
Creates a new Client, with reasonable defaults.
NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling.
NewGetAraContentChannelChannelIdRequest generates requests for GetAraContentChannelChannelId.
NewGetAraContentListenChannelIdChannelMp3Request generates requests for GetAraContentListenChannelIdChannelMp3.
NewGetAraContentPagePlaceIdChannelsRequest generates requests for GetAraContentPagePlaceIdChannels.
NewGetAraContentPagePlaceIdRequest generates requests for GetAraContentPagePlaceId.
NewGetAraContentPlacesRequest generates requests for GetAraContentPlaces.
NewGetGeoRequest generates requests for GetGeo.
NewGetSearchRequest generates requests for GetSearch.
NewHeadAraContentListenChannelIdChannelMp3Request generates requests for HeadAraContentListenChannelIdChannelMp3.
ParseGetAraContentChannelChannelIdResponse parses an HTTP response from a GetAraContentChannelChannelIdWithResponse call.
ParseGetAraContentListenChannelIdChannelMp3Response parses an HTTP response from a GetAraContentListenChannelIdChannelMp3WithResponse call.
ParseGetAraContentPagePlaceIdChannelsResponse parses an HTTP response from a GetAraContentPagePlaceIdChannelsWithResponse call.
ParseGetAraContentPagePlaceIdResponse parses an HTTP response from a GetAraContentPagePlaceIdWithResponse call.
ParseGetAraContentPlacesResponse parses an HTTP response from a GetAraContentPlacesWithResponse call.
ParseGetGeoResponse parses an HTTP response from a GetGeoWithResponse call.
ParseGetSearchResponse parses an HTTP response from a GetSearchWithResponse call.
ParseHeadAraContentListenChannelIdChannelMp3Response parses an HTTP response from a HeadAraContentListenChannelIdChannelMp3WithResponse call.
Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
WithBaseURL overrides the baseURL.
WithFollowRedirectsDisabled prevents the underlying HTTP client from automatically following redirects.
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client.
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request.

# Structs

Channel defines model for Channel.
ChannelPlaceRef defines model for ChannelPlaceRef.
ChannelRef defines model for ChannelRef.
ChannelRefs defines model for ChannelRefs.
Cities defines model for Cities.
Client which conforms to the OpenAPI3 specification for this service.
ClientWithResponses builds on ClientInterface to offer response payloads.
CountryPopularStations defines model for CountryPopularStations.
CountryPopularStations_Items_Item defines model for CountryPopularStations.items.Item.
CountryRef defines model for CountryRef.
Geolocation defines model for Geolocation.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetSearchParams defines parameters for GetSearch.
No description provided by the author
No description provided by the author
LeftPageRef defines model for LeftPageRef.
LocalPickStations defines model for LocalPickStations.
LocalPopularStations defines model for LocalPopularStations.
MoreRef defines model for MoreRef.
MoreRef_Page defines model for MoreRef.Page.
NearbyPlaces defines model for NearbyPlaces.
Place defines model for Place.
PlaceContent defines model for PlaceContent.
PlaceContent_Content_Item defines model for PlaceContent.content.Item.
PlaceRef defines model for PlaceRef.
RightPageRef defines model for RightPageRef.
SearchResult defines model for SearchResult.
SearchResults defines model for SearchResults.
SelectedStations defines model for SelectedStations.
SelectedStations_Items_Item defines model for SelectedStations.items.Item.
Versioned defines model for Versioned.

# Interfaces

The interface specification for the client above.
ClientWithResponsesInterface is the interface specification for the client with responses above.
Doer performs HTTP requests.
Response is implemented by all response types returned by ClientWithResponses.

# Type aliases

ClientOption allows setting custom parameters during construction.
RequestEditorFn is the function signature for the RequestEditor callback function.