ipsonar

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MIT Imports: 9 Imported by: 0

README

IP-Sonar SDK Go

Installation

go get github.com/ip-sonar/ip-sonar-go

See example for usage.

Learn More

Documentation

Overview

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

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

Index

Constants

View Source
const (
	API_SERVER     = "https://api.ip-sonar.com"
	API_KEY_HEADER = "X-API-Key"
)
View Source
const (
	ApiKeyScopes = "apiKey.Scopes"
)

Variables

This section is empty.

Functions

func NewBatchLookupRequest

func NewBatchLookupRequest(server string, params *BatchLookupParams, body BatchLookupJSONRequestBody) (*http.Request, error)

NewBatchLookupRequest calls the generic BatchLookup builder with application/json body

func NewBatchLookupRequestWithBody

func NewBatchLookupRequestWithBody(server string, params *BatchLookupParams, contentType string, body io.Reader) (*http.Request, error)

NewBatchLookupRequestWithBody generates requests for BatchLookup with any type of body

func NewLookupMyRequest

func NewLookupMyRequest(server string, params *LookupMyParams) (*http.Request, error)

NewLookupMyRequest generates requests for LookupMy

func NewLookupRequest

func NewLookupRequest(server string, ip string, params *LookupParams) (*http.Request, error)

NewLookupRequest generates requests for Lookup

Types

type BatchLookupIPResponse

type BatchLookupIPResponse struct {
	Data []IPGeolocation `json:"data"`
}

BatchLookupIPResponse defines model for BatchLookupIPResponse.

type BatchLookupJSONBody

type BatchLookupJSONBody struct {
	// Data Array of IP Addresses
	Data []string `json:"data"`
}

BatchLookupJSONBody defines parameters for BatchLookup.

type BatchLookupJSONRequestBody

type BatchLookupJSONRequestBody BatchLookupJSONBody

BatchLookupJSONRequestBody defines body for BatchLookup for application/json ContentType.

type BatchLookupParams

type BatchLookupParams struct {
	Fields *Fields `form:"fields,omitempty" json:"fields,omitempty"`

	// LocaleCode Geolocation names language code. One of: de, en, es, fr, ja, pt-br, ru, zh-cn
	LocaleCode *Locale `form:"locale_code,omitempty" json:"locale_code,omitempty"`
}

BatchLookupParams defines parameters for BatchLookup.

type BatchLookupRequest

type BatchLookupRequest struct {
	// Data Array of IP Addresses
	Data []string `json:"data"`
}

BatchLookupRequest defines model for BatchLookupRequest.

type BatchLookupResponse

type BatchLookupResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *BatchLookupIPResponse
	JSON401      *ErrorMessageResponse
	JSON429      *ErrorMessageResponse
	JSON500      *ErrorMessageResponse
}

func ParseBatchLookupResponse

func ParseBatchLookupResponse(rsp *http.Response) (*BatchLookupResponse, error)

ParseBatchLookupResponse parses an HTTP response from a BatchLookupWithResponse call

func (BatchLookupResponse) Status

func (r BatchLookupResponse) Status() string

Status returns HTTPResponse.Status

func (BatchLookupResponse) StatusCode

func (r BatchLookupResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

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 (*Client) BatchLookup

func (c *Client) BatchLookup(ctx context.Context, params *BatchLookupParams, body BatchLookupJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) BatchLookupWithBody

func (c *Client) BatchLookupWithBody(ctx context.Context, params *BatchLookupParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) Lookup

func (c *Client) Lookup(ctx context.Context, ip string, params *LookupParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) LookupMy

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

type ClientInterface

type ClientInterface interface {
	// BatchLookupWithBody request with any body
	BatchLookupWithBody(ctx context.Context, params *BatchLookupParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	BatchLookup(ctx context.Context, params *BatchLookupParams, body BatchLookupJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

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

	// Lookup request
	Lookup(ctx context.Context, ip string, params *LookupParams, 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.

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) BatchLookupWithBodyWithResponse

func (c *ClientWithResponses) BatchLookupWithBodyWithResponse(ctx context.Context, params *BatchLookupParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BatchLookupResponse, error)

BatchLookupWithBodyWithResponse request with arbitrary body returning *BatchLookupResponse

func (*ClientWithResponses) BatchLookupWithResponse

func (c *ClientWithResponses) BatchLookupWithResponse(ctx context.Context, params *BatchLookupParams, body BatchLookupJSONRequestBody, reqEditors ...RequestEditorFn) (*BatchLookupResponse, error)

func (*ClientWithResponses) LookupMyWithResponse

func (c *ClientWithResponses) LookupMyWithResponse(ctx context.Context, params *LookupMyParams, reqEditors ...RequestEditorFn) (*LookupMyResponse, error)

LookupMyWithResponse request returning *LookupMyResponse

func (*ClientWithResponses) LookupWithResponse

func (c *ClientWithResponses) LookupWithResponse(ctx context.Context, ip string, params *LookupParams, reqEditors ...RequestEditorFn) (*LookupResponse, error)

LookupWithResponse request returning *LookupResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// BatchLookupWithBodyWithResponse request with any body
	BatchLookupWithBodyWithResponse(ctx context.Context, params *BatchLookupParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BatchLookupResponse, error)

	BatchLookupWithResponse(ctx context.Context, params *BatchLookupParams, body BatchLookupJSONRequestBody, reqEditors ...RequestEditorFn) (*BatchLookupResponse, error)

	// LookupMyWithResponse request
	LookupMyWithResponse(ctx context.Context, params *LookupMyParams, reqEditors ...RequestEditorFn) (*LookupMyResponse, error)

	// LookupWithResponse request
	LookupWithResponse(ctx context.Context, ip string, params *LookupParams, reqEditors ...RequestEditorFn) (*LookupResponse, error)
}

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

type ErrorMessageResponse

type ErrorMessageResponse struct {
	Message string `json:"message"`
}

ErrorMessageResponse defines model for ErrorMessageResponse.

type Fields

type Fields = string

Fields defines model for fields.

type HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type IPGeolocation

type IPGeolocation struct {
	// AccuracyRadius The geographic radius, measured in kilometers, within which the IP address is expected to be located.
	AccuracyRadius *int32  `json:"accuracy_radius,omitempty"`
	CityName       *string `json:"city_name,omitempty"`

	// ContinentCode AF - Africa
	// AN - Antarctica
	// AS - Asia
	// EU - Europe
	// NA - North America
	// OC - Oceania
	// SA - South America
	ContinentCode *string `json:"continent_code,omitempty"`
	ContinentName *string `json:"continent_name,omitempty"`

	// CountryCode ISO 3166-1
	CountryCode *string `json:"country_code,omitempty"`
	CountryName *string `json:"country_name,omitempty"`
	IP          *string `json:"ip,omitempty"`

	// IsInEu A binary indicator (1 or 0) showing whether the IP address's country belongs to the European Union.
	IsInEu     *bool    `json:"is_in_eu,omitempty"`
	Latitude   *float32 `json:"latitude,omitempty"`
	Longitude  *float32 `json:"longitude,omitempty"`
	PostalCode *string  `json:"postal_code,omitempty"`

	// Subdivision1Code ISO 3166-2 region code
	Subdivision1Code *string `json:"subdivision_1_code,omitempty"`
	Subdivision1Name *string `json:"subdivision_1_name,omitempty"`

	// Subdivision2Code ISO 3166-2 region code
	Subdivision2Code *string `json:"subdivision_2_code,omitempty"`
	Subdivision2Name *string `json:"subdivision_2_name,omitempty"`

	// Timezone IANA Timezone https://www.iana.org/time-zones
	Timezone *string `json:"timezone,omitempty"`
}

IPGeolocation defines model for IPGeolocation.

type Locale

type Locale = string

Locale defines model for locale.

type LookupIPResponse

type LookupIPResponse = IPGeolocation

LookupIPResponse defines model for LookupIPResponse.

type LookupMyParams

type LookupMyParams struct {
	Fields *Fields `form:"fields,omitempty" json:"fields,omitempty"`

	// LocaleCode Geolocation names language code. One of: de, en, es, fr, ja, pt-br, ru, zh-cn
	LocaleCode *Locale `form:"locale_code,omitempty" json:"locale_code,omitempty"`
}

LookupMyParams defines parameters for LookupMy.

type LookupMyResponse

type LookupMyResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON401      *ErrorMessageResponse
	JSON404      *ErrorMessageResponse
	JSON429      *ErrorMessageResponse
}

func ParseLookupMyResponse

func ParseLookupMyResponse(rsp *http.Response) (*LookupMyResponse, error)

ParseLookupMyResponse parses an HTTP response from a LookupMyWithResponse call

func (LookupMyResponse) Status

func (r LookupMyResponse) Status() string

Status returns HTTPResponse.Status

func (LookupMyResponse) StatusCode

func (r LookupMyResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type LookupParams

type LookupParams struct {
	Fields *Fields `form:"fields,omitempty" json:"fields,omitempty"`

	// LocaleCode Geolocation names language code. One of: de, en, es, fr, ja, pt-br, ru, zh-cn
	LocaleCode *Locale `form:"locale_code,omitempty" json:"locale_code,omitempty"`
}

LookupParams defines parameters for Lookup.

type LookupResponse

type LookupResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *LookupIPResponse
	JSON401      *ErrorMessageResponse
	JSON404      *ErrorMessageResponse
	JSON429      *ErrorMessageResponse
}

func ParseLookupResponse

func ParseLookupResponse(rsp *http.Response) (*LookupResponse, error)

ParseLookupResponse parses an HTTP response from a LookupWithResponse call

func (LookupResponse) Status

func (r LookupResponse) Status() string

Status returns HTTPResponse.Status

func (LookupResponse) StatusCode

func (r LookupResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type RequestEditorFn

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

RequestEditorFn is the function signature for the RequestEditor callback function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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