GithubHelp home page GithubHelp logo

itextech / radio-garden-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jonasrmichel/radio-garden-go

0.0 0.0 0.0 46 KB

A Go client and CLI for the Radio Garden API

License: Apache License 2.0

Go 100.00%

radio-garden-go's Introduction

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.

radio-garden-go's People

Contributors

jonasrmichel avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.