Categorygithub.com/flowline-io/sdk-adguard-home-api
repositorypackage
0.0.0-20241109154248-701d39df54e9
Repository: https://github.com/flowline-io/sdk-adguard-home-api.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go API client for openapi

AdGuard Home REST-ish API. Our admin web interface is built on top of this REST-ish API.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 0.107
  • Package version: 1.0.0
  • Generator version: 7.10.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://github.com/AdguardTeam/AdGuardHome

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/GIT_USER_ID/GIT_REPO_ID"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to /control

ClassMethodHTTP requestDescription
BlockedServicesAPIBlockedServicesAllGet /blocked_services/allGet available services to use for blocking
BlockedServicesAPIBlockedServicesAvailableServicesGet /blocked_services/servicesGet available services to use for blocking
BlockedServicesAPIBlockedServicesListGet /blocked_services/listGet blocked services list
BlockedServicesAPIBlockedServicesScheduleGet /blocked_services/getGet blocked services
BlockedServicesAPIBlockedServicesScheduleUpdatePut /blocked_services/updateUpdate blocked services
BlockedServicesAPIBlockedServicesSetPost /blocked_services/setSet blocked services list
ClientsAPIAccessListGet /access/listList (dis)allowed clients, blocked hosts, etc.
ClientsAPIAccessSetPost /access/setSet (dis)allowed clients, blocked hosts, etc.
ClientsAPIClientsAddPost /clients/addAdd a new client
ClientsAPIClientsDeletePost /clients/deleteRemove a client
ClientsAPIClientsFindGet /clients/findGet information about clients by their IP addresses or ClientIDs.
ClientsAPIClientsStatusGet /clientsGet information about configured clients
ClientsAPIClientsUpdatePost /clients/updateUpdate client information
DhcpAPICheckActiveDhcpPost /dhcp/find_active_dhcpSearches for an active DHCP server on the network
DhcpAPIDhcpAddStaticLeasePost /dhcp/add_static_leaseAdds a static lease
DhcpAPIDhcpInterfacesGet /dhcp/interfacesGets the available interfaces
DhcpAPIDhcpRemoveStaticLeasePost /dhcp/remove_static_leaseRemoves a static lease
DhcpAPIDhcpResetPost /dhcp/resetReset DHCP configuration
DhcpAPIDhcpResetLeasesPost /dhcp/reset_leasesReset DHCP leases
DhcpAPIDhcpSetConfigPost /dhcp/set_configUpdates the current DHCP server configuration
DhcpAPIDhcpStatusGet /dhcp/statusGets the current DHCP settings and status
DhcpAPIDhcpUpdateStaticLeasePost /dhcp/update_static_leaseUpdates a static lease
FilteringAPIFilteringAddURLPost /filtering/add_urlAdd filter URL or an absolute file path
FilteringAPIFilteringCheckHostGet /filtering/check_hostCheck if host name is filtered
FilteringAPIFilteringConfigPost /filtering/configSet filtering parameters
FilteringAPIFilteringRefreshPost /filtering/refreshReload filtering rules from URLs. This might be needed if new URL was just added and you don't want to wait for automatic refresh to kick in. This API request is ratelimited, so you can call it freely as often as you like, it wont create unnecessary burden on servers that host the URL. This should work as intended, a `force` parameter is offered as last-resort attempt to make filter lists fresh. If you ever find yourself using `force` to make something work that otherwise wont, this is a bug and report it accordingly.
FilteringAPIFilteringRemoveURLPost /filtering/remove_urlRemove filter URL
FilteringAPIFilteringSetRulesPost /filtering/set_rulesSet user-defined filter rules
FilteringAPIFilteringSetURLPost /filtering/set_urlSet URL parameters
FilteringAPIFilteringStatusGet /filtering/statusGet filtering parameters
GlobalAPIBeginUpdatePost /updateBegin auto-upgrade procedure
GlobalAPICacheClearPost /cache_clearClear DNS cache
GlobalAPIDnsConfigPost /dns_configSet general DNS parameters
GlobalAPIDnsInfoGet /dns_infoGet general DNS parameters
GlobalAPIGetProfileGet /profile
GlobalAPIGetVersionJsonPost /version.jsonGets information about the latest available version of AdGuard
GlobalAPILoginPost /loginPerform administrator log-in
GlobalAPILogoutGet /logoutPerform administrator log-out
GlobalAPIMobileConfigDoHGet /apple/doh.mobileconfigGet DNS over HTTPS .mobileconfig.
GlobalAPIMobileConfigDoTGet /apple/dot.mobileconfigGet DNS over TLS .mobileconfig.
GlobalAPISetProtectionPost /protectionSet protection state and duration
GlobalAPIStatusGet /statusGet DNS server current status and general settings
GlobalAPITestUpstreamDNSPost /test_upstream_dnsTest upstream configuration
GlobalAPIUpdateProfilePut /profile/updateUpdates current user info
I18nAPIChangeLanguagePost /i18n/change_languageChange current language. Argument must be an ISO 639-1 two-letter code.
I18nAPICurrentLanguageGet /i18n/current_languageGet currently set language. Result is ISO 639-1 two-letter code. Empty result means default language.
InstallAPIInstallCheckConfigPost /install/check_configChecks configuration
InstallAPIInstallConfigurePost /install/configureApplies the initial configuration.
InstallAPIInstallGetAddressesGet /install/get_addressesGets the network interfaces information.
LogAPIGetQueryLogConfigGet /querylog/configGet query log parameters
LogAPIPutQueryLogConfigPut /querylog/config/updateSet query log parameters
LogAPIQueryLogGet /querylogGet DNS server query log.
LogAPIQueryLogConfigPost /querylog_configSet query log parameters
LogAPIQueryLogInfoGet /querylog_infoGet query log parameters
LogAPIQuerylogClearPost /querylog_clearClear query log
MobileconfigAPIMobileConfigDoHGet /apple/doh.mobileconfigGet DNS over HTTPS .mobileconfig.
MobileconfigAPIMobileConfigDoTGet /apple/dot.mobileconfigGet DNS over TLS .mobileconfig.
ParentalAPIParentalDisablePost /parental/disableDisable parental filtering
ParentalAPIParentalEnablePost /parental/enableEnable parental filtering
ParentalAPIParentalStatusGet /parental/statusGet parental filtering status
RewriteAPIRewriteAddPost /rewrite/addAdd a new Rewrite rule
RewriteAPIRewriteDeletePost /rewrite/deleteRemove a Rewrite rule
RewriteAPIRewriteListGet /rewrite/listGet list of Rewrite rules
RewriteAPIRewriteUpdatePut /rewrite/updateUpdate a Rewrite rule
SafebrowsingAPISafebrowsingDisablePost /safebrowsing/disableDisable safebrowsing
SafebrowsingAPISafebrowsingEnablePost /safebrowsing/enableEnable safebrowsing
SafebrowsingAPISafebrowsingStatusGet /safebrowsing/statusGet safebrowsing status
SafesearchAPISafesearchDisablePost /safesearch/disableDisable safesearch
SafesearchAPISafesearchEnablePost /safesearch/enableEnable safesearch
SafesearchAPISafesearchSettingsPut /safesearch/settingsUpdate safesearch settings
SafesearchAPISafesearchStatusGet /safesearch/statusGet safesearch status
StatsAPIGetStatsConfigGet /stats/configGet statistics parameters
StatsAPIPutStatsConfigPut /stats/config/updateSet statistics parameters
StatsAPIStatsGet /statsGet DNS server statistics
StatsAPIStatsConfigPost /stats_configSet statistics parameters
StatsAPIStatsInfoGet /stats_infoGet statistics parameters
StatsAPIStatsResetPost /stats_resetReset all statistics to zeroes
TlsAPITlsConfigurePost /tls/configureUpdates current TLS configuration
TlsAPITlsStatusGet /tls/statusReturns TLS configuration and its status
TlsAPITlsValidatePost /tls/validateChecks if the current TLS configuration is valid

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

basicAuth

  • Type: HTTP basic authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextBasicAuth, openapi.BasicAuth{
	UserName: "username",
	Password: "password",
})
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author