qrzlog

package module
v0.2.38 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

README

PkgGoDev Go Report Card

Go API client for QRZ.com Logbook

A GoLang client library for QRZ.com's Logbook data service. The service provides real-time access to information from QRZ.com logbooks. The API is documented here.

This client library was generated based on the OpenAPI specification in the api/openapi.yaml file. However, the API itself is not well-described by OpenAPI, so the generated library is supplemented with wrapper.go.

A simple application to demonstrate how to integrate the library is located in cmd/qrz-logbook/main.go.

A QRZ.com XML subscription is required to take full advantage of the API. A description of subscription plans and rates is available on the QRZ.com website.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	DefaultApi *DefaultApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the QRZ Logbook API API v1.0.0 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

ChangeBasePath changes base path to allow switching to mocks

func (*APIClient) GetConfig

func (c *APIClient) GetConfig() *Configuration

Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the OpenAPI operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

APIResponse stores the API response returned by the server.

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

NewAPIResponse returns a new APIResonse object.

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

NewAPIResponseWithError returns a new APIResponse object with the provided error message.

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	Debug         bool              `json:"debug,omitempty"`
	Servers       []ServerConfiguration
	HTTPClient    *http.Client
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request

func (*Configuration) ServerUrl

func (c *Configuration) ServerUrl(index int, variables map[string]string) (string, error)

ServerUrl returns URL based on server settings

type DefaultApiService

type DefaultApiService service

DefaultApiService DefaultApi service

func (*DefaultApiService) RootPost

func (a *DefaultApiService) RootPost(ctx _context.Context, kEY string, aCTION string, localVarOptionals *RootPostOpts) (Response, *_nethttp.Response, error)

RootPost The do-everything endpoint

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param kEY A QRZ supplied logbook access key
  • @param aCTION Type of request, i.e. INSERT, DELETE, UPLOAD, etc.
  • @param optional nil or *RootPostOpts - Optional Parameters:
  • @param "ADIF" (optional.String) - ADIF formatted input data
  • @param "OPTION" (optional.String) - Action-specific options
  • @param "LOGIDS" (optional.String) - A comma separated list of integer logid values

@return Response

type DeleteResponse

type DeleteResponse struct {
	Count  uint64
	Result string
	// The log IDs which were not deleted; Result will be PARTIAL
	LogIds []string
}

func Delete

func Delete(ctx context.Context, key *string, ids []string) (*DeleteResponse, error)

type FetchResponse

type FetchResponse struct {
	Adif   string
	Count  uint64
	Result string
}

func Fetch

func Fetch(ctx context.Context, key *string) (*FetchResponse, error)

type GenericOpenAPIError

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

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type InsertResponse

type InsertResponse struct {
	Count  uint64
	Result string
	LogId  string
}

func Insert

func Insert(ctx context.Context, key *string, adif string, replace bool) (*InsertResponse, error)

type Request

type Request struct {
	// A QRZ supplied logbook access key
	KEY string `json:"KEY"`
	// Type of request, i.e. INSERT, DELETE, UPLOAD, etc.
	ACTION string `json:"ACTION"`
	// ADIF formatted input data
	ADIF string `json:"ADIF,omitempty"`
	// Action-specific options
	OPTION string `json:"OPTION,omitempty"`
	// A comma separated list of integer logid values
	LOGIDS string `json:"LOGIDS,omitempty"`
}

Request struct for Request

type Response

type Response struct {
	// OK when the operation succeeds, FAIL when the operation failed, AUTH when API Access lacked sufficient privileges for the operation, or other action-specific codes
	RESULT string `json:"RESULT,omitempty"`
	// Used with RESULT=FAIL to describe the specific reason for failure
	REASON string `json:"REASON,omitempty"`
	// A comma separated list of logid values that were affected by the action
	LOGIDS string `json:"LOGIDS,omitempty"`
	// The logid value of the record that was inserted or replaced. (Singular \"LOGID\" response only used by INSERT as it is a single record operation.)
	LOGID string `json:"LOGID,omitempty"`
	// The number of QSO records that were affected by the action
	COUNT string `json:"COUNT,omitempty"`
	// Used for action-specific data such as status reports
	DATA string `json:"DATA,omitempty"`
}

Response struct for Response

type RootPostOpts

type RootPostOpts struct {
	ADIF   optional.String
	OPTION optional.String
	LOGIDS optional.String
}

RootPostOpts Optional parameters for the method 'RootPost'

type ServerConfiguration

type ServerConfiguration struct {
	Url         string
	Description string
	Variables   map[string]ServerVariable
}

ServerConfiguration stores the information about a server

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable

type StatusResponse

type StatusResponse struct {
	Action    string
	BookId    string
	BookName  string
	Callsign  string
	Confirmed uint64
	Count     uint64
	DxccCount uint64
	EndDate   string
	Owner     string
	Result    string
	StartDate string
}

func Status

func Status(ctx context.Context, key *string) (*StatusResponse, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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