From da289017a55538e0cdca76e89414cd7871265988 Mon Sep 17 00:00:00 2001 From: Marc Brugger Date: Mon, 13 Nov 2023 21:09:08 +0100 Subject: [PATCH] Generate types from openapi (#201) * generate model from openAPI schema * implement replica status #231 * Sync "Pause service blocking schedule" #234 * Sync "Safe Search Provider" #200 --- .github/workflows/e2e.yaml | 2 + .gitignore | 3 +- .oapi-codegen.yaml | 3 + Dockerfile | 2 +- Makefile | 27 +- go.mod | 30 +- go.sum | 73 +- openapi/main.go | 63 + pkg/client/client-methods.go | 83 + pkg/client/client.go | 299 +- pkg/client/client_test.go | 158 +- pkg/client/model/client/client.go | 144 + pkg/client/model/client/interface.go | 15 + pkg/client/model/client/resty.go | 27 + pkg/client/model/model-functions.go | 372 + pkg/client/model/model_generated.go | 10566 ++++++++++++++++ .../model/model_suite_test.go} | 4 +- .../model/model_test.go} | 297 +- pkg/mocks/client/mock.go | 274 +- pkg/sync/http.go | 23 +- pkg/sync/index.html | 34 +- pkg/sync/sync.go | 169 +- pkg/sync/sync_test.go | 355 +- pkg/types/deepcopy_generated.go | 45 - pkg/types/dhcp.go | 101 - pkg/types/dns.go | 71 - pkg/types/features.go | 2 +- pkg/types/types.go | 306 - pkg/utils/clone.go | 15 + pkg/utils/ptr.go | 14 + pkg/versions/versions.go | 11 +- testdata/blockedservicesschedule-get.json | 22 + .../e2e/bin/read-latest-replica-config.sh | 6 + testdata/e2e/resources/AdGuardHome.yaml | 206 + testdata/e2e/templates/NOTES.txt | 4 + testdata/e2e/templates/configmap-origin.yaml | 168 +- testdata/e2e/templates/configmap-sync.yaml | 20 +- testdata/e2e/templates/rbac.yaml | 2 - testdata/e2e/values.yaml | 3 +- testdata/filtering-status.json | 5 +- 40 files changed, 12567 insertions(+), 1457 deletions(-) create mode 100644 .oapi-codegen.yaml create mode 100644 openapi/main.go create mode 100644 pkg/client/client-methods.go create mode 100644 pkg/client/model/client/client.go create mode 100644 pkg/client/model/client/interface.go create mode 100644 pkg/client/model/client/resty.go create mode 100644 pkg/client/model/model-functions.go create mode 100644 pkg/client/model/model_generated.go rename pkg/{types/types_suite_test.go => client/model/model_suite_test.go} (75%) rename pkg/{types/types_test.go => client/model/model_test.go} (51%) delete mode 100644 pkg/types/dhcp.go delete mode 100644 pkg/types/dns.go create mode 100644 pkg/utils/clone.go create mode 100644 pkg/utils/ptr.go create mode 100644 testdata/blockedservicesschedule-get.json create mode 100755 testdata/e2e/bin/read-latest-replica-config.sh create mode 100644 testdata/e2e/resources/AdGuardHome.yaml create mode 100644 testdata/e2e/templates/NOTES.txt diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 7257885..09611a1 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -31,3 +31,5 @@ jobs: run: ./testdata/e2e/bin/show-replica-logs.sh - name: Show Sync Logs run: ./testdata/e2e/bin/show-sync-logs.sh + - name: Read latest replica config + run: ./testdata/e2e/bin/read-latest-replica-config.sh diff --git a/.gitignore b/.gitignore index 8a70631..f26fce9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .vscode .idea -coverage.out +.run +coverage.out* dist adguardhome-sync main diff --git a/.oapi-codegen.yaml b/.oapi-codegen.yaml new file mode 100644 index 0000000..bf97aa7 --- /dev/null +++ b/.oapi-codegen.yaml @@ -0,0 +1,3 @@ +output-options: + client-type-name: AdguardHomeClient + response-type-suffix: Resp diff --git a/Dockerfile b/Dockerfile index 9f59ff2..52b86f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20-bullseye as builder +FROM golang:1.21-bullseye as builder WORKDIR /go/src/app diff --git a/Makefile b/Makefile index 5bbefd0..0cfe3a2 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,8 @@ test: generate lint test-ci # Run ci tests test-ci: mocks tidy - go test ./... -coverprofile=coverage.out + go test ./... -coverprofile=coverage.out.tmp + cat coverage.out.tmp | grep -v "_generated.go" > coverage.out go tool cover -func=coverage.out mocks: mockgen @@ -40,6 +41,7 @@ $(LOCALBIN): ## Tool Binaries SEMVER ?= $(LOCALBIN)/semver +OAPI_CODEGEN ?= $(LOCALBIN)/oapi-codegen MOCKGEN ?= $(LOCALBIN)/mockgen GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint GORELEASER ?= $(LOCALBIN)/goreleaser @@ -47,16 +49,21 @@ DEEPCOPY_GEN ?= $(LOCALBIN)/deepcopy-gen ## Tool Versions SEMVER_VERSION ?= v1.1.3 +OAPI_CODEGEN_VERSION ?= v2.0.0 MOCKGEN_VERSION ?= v1.6.0 -GOLANGCI_LINT_VERSION ?= v1.53.2 -GORELEASER_VERSION ?= v1.18.2 -DEEPCOPY_GEN_VERSION ?= v0.27.2 +GOLANGCI_LINT_VERSION ?= v1.55.2 +GORELEASER_VERSION ?= v1.22.1 +DEEPCOPY_GEN_VERSION ?= v0.28.3 ## Tool Installer .PHONY: semver semver: $(SEMVER) ## Download semver locally if necessary. $(SEMVER): $(LOCALBIN) test -s $(LOCALBIN)/semver || GOBIN=$(LOCALBIN) go install github.com/bakito/semver@$(SEMVER_VERSION) +.PHONY: oapi-codegen +oapi-codegen: $(OAPI_CODEGEN) ## Download oapi-codegen locally if necessary. +$(OAPI_CODEGEN): $(LOCALBIN) + test -s $(LOCALBIN)/oapi-codegen || GOBIN=$(LOCALBIN) go install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION) .PHONY: mockgen mockgen: $(MOCKGEN) ## Download mockgen locally if necessary. $(MOCKGEN): $(LOCALBIN) @@ -79,12 +86,14 @@ $(DEEPCOPY_GEN): $(LOCALBIN) update-toolbox-tools: @rm -f \ $(LOCALBIN)/semver \ + $(LOCALBIN)/oapi-codegen \ $(LOCALBIN)/mockgen \ $(LOCALBIN)/golangci-lint \ $(LOCALBIN)/goreleaser \ $(LOCALBIN)/deepcopy-gen toolbox makefile -f $(LOCALDIR)/Makefile \ github.com/bakito/semver \ + github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen \ github.com/golang/mock/mockgen \ github.com/golangci/golangci-lint/cmd/golangci-lint \ github.com/goreleaser/goreleaser \ @@ -116,3 +125,13 @@ kind-create: kind-test: @./testdata/e2e/bin/install-chart.sh + +model: oapi-codegen + @mkdir -p tmp + go run openapi/main.go v0.107.40 + $(OAPI_CODEGEN) -package model -generate types,client -config .oapi-codegen.yaml tmp/schema.yaml > pkg/client/model/model_generated.go + +model-diff: + go run openapi/main.go v0.107.40 + go run openapi/main.go + diff tmp/schema.yaml tmp/schema-master.yaml diff --git a/go.mod b/go.mod index fcb0642..b9ff8c4 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/google/uuid v1.4.0 github.com/jinzhu/copier v0.4.0 github.com/mitchellh/go-homedir v1.1.0 + github.com/oapi-codegen/runtime v1.0.0 github.com/onsi/ginkgo/v2 v2.13.1 github.com/onsi/gomega v1.30.0 github.com/robfig/cron/v3 v3.0.1 @@ -16,32 +17,39 @@ require ( github.com/spf13/viper v1.17.0 go.uber.org/zap v1.26.0 golang.org/x/mod v0.14.0 + gopkg.in/yaml.v3 v3.0.1 + k8s.io/apimachinery v0.28.3 ) require ( - github.com/bytedance/sonic v1.9.1 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect + github.com/bytedance/sonic v1.10.0 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect + github.com/chenzhuoyu/iasm v0.9.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/go-playground/validator/v10 v10.15.1 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/goccy/go-json v0.10.2 // indirect + github.com/gogo/protobuf v1.3.2 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/leodido/go-urn v1.2.4 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-isatty v0.0.19 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.3.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -52,8 +60,8 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect - go.uber.org/multierr v1.10.0 // indirect - golang.org/x/arch v0.3.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/arch v0.4.0 // indirect golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/net v0.17.0 // indirect @@ -61,6 +69,12 @@ require ( golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.14.0 // indirect google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + k8s.io/klog/v2 v2.100.1 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect ) diff --git a/go.sum b/go.sum index af09e81..514f21c 100644 --- a/go.sum +++ b/go.sum @@ -38,13 +38,21 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= +github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +github.com/bytedance/sonic v1.10.0/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0= +github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA= +github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo= +github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -74,6 +82,7 @@ github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SU github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= @@ -81,14 +90,16 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.15.1 h1:BSe8uhN+xQ4r5guV/ywQI4gO59C2raYcGffYWZEjZzM= +github.com/go-playground/validator/v10 v10.15.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-resty/resty/v2 v2.10.0 h1:Qla4W/+TMmv0fOeeRqzEpXPLfTUnR5HZ1+lGs+CkiCo= github.com/go-resty/resty/v2 v2.10.0/go.mod h1:iiP/OpA0CkcL3IGt1O0+/SIItFUbkkyw5BGXiVdTu+A= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -130,9 +141,12 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -146,8 +160,8 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= @@ -169,10 +183,13 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -194,6 +211,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/oapi-codegen/runtime v1.0.0 h1:P4rqFX5fMFWqRzY9M/3YF9+aPSPPB06IzP2P7oOxrWo= +github.com/oapi-codegen/runtime v1.0.0/go.mod h1:LmCUMQuPB4M/nLXilQXhHw+BLZdDb18B34OO356yJ/A= github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU= github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= @@ -208,7 +229,7 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= @@ -226,6 +247,7 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -259,13 +281,13 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc= +golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -414,7 +436,6 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -482,6 +503,7 @@ golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -490,6 +512,7 @@ golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -594,11 +617,17 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= +gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -609,7 +638,19 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +k8s.io/apimachinery v0.28.3 h1:B1wYx8txOaCQG0HmYF6nbpU8dg6HvA06x5tEffvOe7A= +k8s.io/apimachinery v0.28.3/go.mod h1:uQTKmIqs+rAYaq+DFaoD2X7pcjLOqbQX2AOiO0nIpb8= +k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= +k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk= +sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/openapi/main.go b/openapi/main.go new file mode 100644 index 0000000..57a9621 --- /dev/null +++ b/openapi/main.go @@ -0,0 +1,63 @@ +package main + +import ( + "fmt" + "io" + "log" + "net/http" + "os" + + "gopkg.in/yaml.v3" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" +) + +func main() { + version := "master" + fileName := "schema-master.yaml" + if len(os.Args) > 1 { + version = os.Args[1] + fileName = "schema.yaml" + } + log.Printf("Patching schema version %s\n", version) + + resp, err := http.Get(fmt.Sprintf("https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/%s/openapi/openapi.yaml", version)) + if err != nil { + log.Fatalln(err) + } + defer func() { _ = resp.Body.Close() }() + data, err := io.ReadAll(resp.Body) + if err != nil { + log.Fatalln(err) + } + schema := make(map[string]interface{}) + err = yaml.Unmarshal(data, &schema) + if err != nil { + log.Fatalln(err) + } + + if requestBodies, ok, _ := unstructured.NestedMap(schema, "components", "requestBodies"); ok { + for k := range requestBodies { + _ = unstructured.SetNestedField(schema, k+"Body", "components", "requestBodies", k, "x-go-name") + } + } + + if dnsInfo, ok, _ := unstructured.NestedMap(schema, + "paths", "/dns_info", "get", "responses", "200", "content", "application/json", "schema"); ok { + if allOf, ok, _ := unstructured.NestedSlice(dnsInfo, "allOf"); ok && len(allOf) == 2 { + delete(dnsInfo, "allOf") + if err := unstructured.SetNestedMap(schema, allOf[0].(map[string]interface{}), + "paths", "/dns_info", "get", "responses", "200", "content", "application/json", "schema"); err != nil { + log.Fatalln(err) + } + } + } + b, err := yaml.Marshal(&schema) + if err != nil { + log.Fatalln(err) + } + log.Printf("Writing schema file tmp/%s", fileName) + err = os.WriteFile("tmp/"+fileName, b, 0o600) + if err != nil { + log.Fatalln(err) + } +} diff --git a/pkg/client/client-methods.go b/pkg/client/client-methods.go new file mode 100644 index 0000000..330c5d2 --- /dev/null +++ b/pkg/client/client-methods.go @@ -0,0 +1,83 @@ +package client + +import ( + "encoding/json" + "net/http" + + "github.com/go-resty/resty/v2" +) + +func (cl *client) doGet(req *resty.Request, url string) error { + rl := cl.log.With("method", "GET", "path", url) + if cl.client.UserInfo != nil { + rl = rl.With("username", cl.client.UserInfo.Username) + } + req.ForceContentType("application/json") + rl.Debug("do get") + resp, err := req.Get(url) + if err != nil { + if resp != nil && resp.StatusCode() == http.StatusFound { + loc := resp.Header().Get("Location") + if loc == "/install.html" || loc == "/control/install.html" { + return ErrSetupNeeded + } + } + rl.With("status", resp.StatusCode(), "body", string(resp.Body()), "error", err).Debug("error in do get") + return detailedError(resp, err) + } + rl.With( + "status", resp.StatusCode(), + "body", string(resp.Body()), + "content-type", resp.Header()["Content-Type"], + ).Debug("got response") + if resp.StatusCode() != http.StatusOK { + return detailedError(resp, nil) + } + return nil +} + +func (cl *client) doPost(req *resty.Request, url string) error { + rl := cl.log.With("method", "POST", "path", url) + if cl.client.UserInfo != nil { + rl = rl.With("username", cl.client.UserInfo.Username) + } + b, _ := json.Marshal(req.Body) + rl.With("body", string(b)).Debug("do post") + resp, err := req.Post(url) + if err != nil { + rl.With("status", resp.StatusCode(), "body", string(resp.Body()), "error", err).Debug("error in do post") + return detailedError(resp, err) + } + rl.With( + "status", resp.StatusCode(), + "body", string(resp.Body()), + "content-type", contentType(resp), + ).Debug("got response") + if resp.StatusCode() != http.StatusOK { + return detailedError(resp, nil) + } + return nil +} + +func (cl *client) doPut(req *resty.Request, url string) error { + rl := cl.log.With("method", "PUT", "path", url) + if cl.client.UserInfo != nil { + rl = rl.With("username", cl.client.UserInfo.Username) + } + b, _ := json.Marshal(req.Body) + rl.With("body", string(b)).Debug("do put") + resp, err := req.Put(url) + if err != nil { + rl.With("status", resp.StatusCode(), "body", string(resp.Body()), "error", err).Debug("error in do put") + return detailedError(resp, err) + } + rl.With( + "status", resp.StatusCode(), + "body", string(resp.Body()), + "content-type", contentType(resp), + ).Debug("got response") + if resp.StatusCode() != http.StatusOK { + return detailedError(resp, nil) + } + return nil +} diff --git a/pkg/client/client.go b/pkg/client/client.go index 273b65d..9892fff 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -2,7 +2,6 @@ package client import ( "crypto/tls" - "encoding/json" "errors" "fmt" "net/http" @@ -12,8 +11,10 @@ import ( "strconv" "strings" + "github.com/bakito/adguardhome-sync/pkg/client/model" "github.com/bakito/adguardhome-sync/pkg/log" "github.com/bakito/adguardhome-sync/pkg/types" + "github.com/bakito/adguardhome-sync/pkg/utils" "github.com/go-resty/resty/v2" "go.uber.org/zap" ) @@ -88,43 +89,47 @@ func New(config types.AdGuardInstance) (Client, error) { // Client AdguardHome API client interface type Client interface { Host() string - Status() (*types.Status, error) + Status() (*model.ServerStatus, error) ToggleProtection(enable bool) error - RewriteList() (*types.RewriteEntries, error) - AddRewriteEntries(e ...types.RewriteEntry) error - DeleteRewriteEntries(e ...types.RewriteEntry) error - Filtering() (*types.FilteringStatus, error) - ToggleFiltering(enabled bool, interval float64) error - AddFilters(whitelist bool, e ...types.Filter) error - DeleteFilters(whitelist bool, e ...types.Filter) error - UpdateFilters(whitelist bool, e ...types.Filter) error + RewriteList() (*model.RewriteEntries, error) + AddRewriteEntries(e ...model.RewriteEntry) error + DeleteRewriteEntries(e ...model.RewriteEntry) error + Filtering() (*model.FilterStatus, error) + ToggleFiltering(enabled bool, interval int) error + AddFilters(whitelist bool, e ...model.Filter) error + DeleteFilters(whitelist bool, e ...model.Filter) error + UpdateFilters(whitelist bool, e ...model.Filter) error RefreshFilters(whitelist bool) error - SetCustomRules(rules types.UserRules) error + SetCustomRules(rules *[]string) error SafeBrowsing() (bool, error) ToggleSafeBrowsing(enable bool) error Parental() (bool, error) ToggleParental(enable bool) error - SafeSearch() (bool, error) - ToggleSafeSearch(enable bool) error - Services() (types.Services, error) - SetServices(services types.Services) error - Clients() (*types.Clients, error) - AddClients(client ...types.Client) error - UpdateClients(client ...types.Client) error - DeleteClients(client ...types.Client) error - QueryLogConfig() (*types.QueryLogConfig, error) - SetQueryLogConfig(enabled bool, interval float64, anonymizeClientIP bool) error - StatsConfig() (*types.IntervalConfig, error) - SetStatsConfig(interval float64) error + SafeSearchConfig() (*model.SafeSearchConfig, error) + SetSafeSearchConfig(settings *model.SafeSearchConfig) error + ProfileInfo() (*model.ProfileInfo, error) + SetProfileInfo(settings *model.ProfileInfo) error + BlockedServices() (*model.BlockedServicesArray, error) + BlockedServicesSchedule() (*model.BlockedServicesSchedule, error) + SetBlockedServices(services *model.BlockedServicesArray) error + SetBlockedServicesSchedule(schedule *model.BlockedServicesSchedule) error + Clients() (*model.Clients, error) + AddClients(client ...*model.Client) error + UpdateClients(client ...*model.Client) error + DeleteClients(client ...*model.Client) error + QueryLogConfig() (*model.QueryLogConfig, error) + SetQueryLogConfig(*model.QueryLogConfig) error + StatsConfig() (*model.StatsConfig, error) + SetStatsConfig(sc *model.StatsConfig) error Setup() error - AccessList() (*types.AccessList, error) - SetAccessList(*types.AccessList) error - DNSConfig() (*types.DNSConfig, error) - SetDNSConfig(*types.DNSConfig) error - DHCPServerConfig() (*types.DHCPServerConfig, error) - SetDHCPServerConfig(*types.DHCPServerConfig) error - AddDHCPStaticLeases(leases ...types.Lease) error - DeleteDHCPStaticLeases(leases ...types.Lease) error + AccessList() (*model.AccessList, error) + SetAccessList(*model.AccessList) error + DNSConfig() (*model.DNSConfig, error) + SetDNSConfig(*model.DNSConfig) error + DhcpConfig() (*model.DhcpStatus, error) + SetDhcpConfig(*model.DhcpStatus) error + AddDHCPStaticLeases(leases ...model.DhcpStaticLease) error + DeleteDHCPStaticLeases(leases ...model.DhcpStaticLease) error } type client struct { @@ -138,58 +143,6 @@ func (cl *client) Host() string { return cl.host } -func (cl *client) doGet(req *resty.Request, url string) error { - rl := cl.log.With("method", "GET", "path", url) - if cl.client.UserInfo != nil { - rl = rl.With("username", cl.client.UserInfo.Username) - } - req.ForceContentType("application/json") - rl.Debug("do get") - resp, err := req.Get(url) - if err != nil { - if resp != nil && resp.StatusCode() == http.StatusFound { - loc := resp.Header().Get("Location") - if loc == "/install.html" || loc == "/control/install.html" { - return ErrSetupNeeded - } - } - rl.With("status", resp.StatusCode(), "body", string(resp.Body()), "error", err).Debug("error in do get") - return detailedError(resp, err) - } - rl.With( - "status", resp.StatusCode(), - "body", string(resp.Body()), - "content-type", resp.Header()["Content-Type"], - ).Debug("got response") - if resp.StatusCode() != http.StatusOK { - return detailedError(resp, nil) - } - return nil -} - -func (cl *client) doPost(req *resty.Request, url string) error { - rl := cl.log.With("method", "POST", "path", url) - if cl.client.UserInfo != nil { - rl = rl.With("username", cl.client.UserInfo.Username) - } - b, _ := json.Marshal(req.Body) - rl.With("body", string(b)).Debug("do post") - resp, err := req.Post(url) - if err != nil { - rl.With("status", resp.StatusCode(), "body", string(resp.Body()), "error", err).Debug("error in do post") - return detailedError(resp, err) - } - rl.With( - "status", resp.StatusCode(), - "body", string(resp.Body()), - "content-type", contentType(resp), - ).Debug("got response") - if resp.StatusCode() != http.StatusOK { - return detailedError(resp, nil) - } - return nil -} - func contentType(resp *resty.Response) string { if ct, ok := resp.Header()["Content-Type"]; ok { if len(ct) != 1 { @@ -200,20 +153,20 @@ func contentType(resp *resty.Response) string { return "" } -func (cl *client) Status() (*types.Status, error) { - status := &types.Status{} +func (cl *client) Status() (*model.ServerStatus, error) { + status := &model.ServerStatus{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(status), "status") cl.version = status.Version return status, err } -func (cl *client) RewriteList() (*types.RewriteEntries, error) { - rewrites := &types.RewriteEntries{} +func (cl *client) RewriteList() (*model.RewriteEntries, error) { + rewrites := &model.RewriteEntries{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(&rewrites), "/rewrite/list") return rewrites, err } -func (cl *client) AddRewriteEntries(entries ...types.RewriteEntry) error { +func (cl *client) AddRewriteEntries(entries ...model.RewriteEntry) error { for i := range entries { e := entries[i] cl.log.With("domain", e.Domain, "answer", e.Answer).Info("Add rewrite entry") @@ -225,7 +178,7 @@ func (cl *client) AddRewriteEntries(entries ...types.RewriteEntry) error { return nil } -func (cl *client) DeleteRewriteEntries(entries ...types.RewriteEntry) error { +func (cl *client) DeleteRewriteEntries(entries ...model.RewriteEntry) error { for i := range entries { e := entries[i] cl.log.With("domain", e.Domain, "answer", e.Answer).Info("Delete rewrite entry") @@ -253,16 +206,8 @@ func (cl *client) ToggleParental(enable bool) error { return cl.toggleBool("parental", enable) } -func (cl *client) SafeSearch() (bool, error) { - return cl.toggleStatus("safesearch") -} - -func (cl *client) ToggleSafeSearch(enable bool) error { - return cl.toggleBool("safesearch", enable) -} - func (cl *client) toggleStatus(mode string) (bool, error) { - fs := &types.EnableConfig{} + fs := &model.EnableConfig{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(fs), fmt.Sprintf("/%s/status", mode)) return fs.Enabled, err } @@ -278,16 +223,16 @@ func (cl *client) toggleBool(mode string, enable bool) error { return cl.doPost(cl.client.R().EnableTrace(), fmt.Sprintf("/%s/%s", mode, target)) } -func (cl *client) Filtering() (*types.FilteringStatus, error) { - f := &types.FilteringStatus{} +func (cl *client) Filtering() (*model.FilterStatus, error) { + f := &model.FilterStatus{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(f), "/filtering/status") return f, err } -func (cl *client) AddFilters(whitelist bool, filters ...types.Filter) error { +func (cl *client) AddFilters(whitelist bool, filters ...model.Filter) error { for _, f := range filters { - cl.log.With("url", f.URL, "whitelist", whitelist, "enabled", f.Enabled).Info("Add filter") - ff := &types.Filter{Name: f.Name, URL: f.URL, Whitelist: whitelist} + cl.log.With("url", f.Url, "whitelist", whitelist, "enabled", f.Enabled).Info("Add filter") + ff := &model.AddUrlRequest{Name: utils.Ptr(f.Name), Url: utils.Ptr(f.Url), Whitelist: utils.Ptr(whitelist)} err := cl.doPost(cl.client.R().EnableTrace().SetBody(ff), "/filtering/add_url") if err != nil { return err @@ -296,10 +241,10 @@ func (cl *client) AddFilters(whitelist bool, filters ...types.Filter) error { return nil } -func (cl *client) DeleteFilters(whitelist bool, filters ...types.Filter) error { +func (cl *client) DeleteFilters(whitelist bool, filters ...model.Filter) error { for _, f := range filters { - cl.log.With("url", f.URL, "whitelist", whitelist, "enabled", f.Enabled).Info("Delete filter") - ff := &types.Filter{URL: f.URL, Whitelist: whitelist} + cl.log.With("url", f.Url, "whitelist", whitelist, "enabled", f.Enabled).Info("Delete filter") + ff := &model.RemoveUrlRequest{Url: utils.Ptr(f.Url), Whitelist: utils.Ptr(whitelist)} err := cl.doPost(cl.client.R().EnableTrace().SetBody(ff), "/filtering/remove_url") if err != nil { return err @@ -308,10 +253,13 @@ func (cl *client) DeleteFilters(whitelist bool, filters ...types.Filter) error { return nil } -func (cl *client) UpdateFilters(whitelist bool, filters ...types.Filter) error { +func (cl *client) UpdateFilters(whitelist bool, filters ...model.Filter) error { for _, f := range filters { - cl.log.With("url", f.URL, "whitelist", whitelist, "enabled", f.Enabled).Info("Update filter") - fu := &types.FilterUpdate{Whitelist: whitelist, URL: f.URL, Data: types.Filter{ID: f.ID, Name: f.Name, URL: f.URL, Whitelist: whitelist, Enabled: f.Enabled}} + cl.log.With("url", f.Url, "whitelist", whitelist, "enabled", f.Enabled).Info("Update filter") + fu := &model.FilterSetUrl{ + Whitelist: utils.Ptr(whitelist), Url: utils.Ptr(f.Url), + Data: &model.FilterSetUrlData{Name: f.Name, Url: f.Url, Enabled: f.Enabled}, + } err := cl.doPost(cl.client.R().EnableTrace().SetBody(fu), "/filtering/set_url") if err != nil { return err @@ -322,7 +270,7 @@ func (cl *client) UpdateFilters(whitelist bool, filters ...types.Filter) error { func (cl *client) RefreshFilters(whitelist bool) error { cl.log.With("whitelist", whitelist).Info("Refresh filter") - return cl.doPost(cl.client.R().EnableTrace().SetBody(&types.RefreshFilter{Whitelist: whitelist}), "/filtering/refresh") + return cl.doPost(cl.client.R().EnableTrace().SetBody(&model.FilterRefreshRequest{Whitelist: utils.Ptr(whitelist)}), "/filtering/refresh") } func (cl *client) ToggleProtection(enable bool) error { @@ -330,41 +278,52 @@ func (cl *client) ToggleProtection(enable bool) error { return cl.doPost(cl.client.R().EnableTrace().SetBody(&types.Protection{ProtectionEnabled: enable}), "/dns_config") } -func (cl *client) SetCustomRules(rules types.UserRules) error { - cl.log.With("rules", len(rules)).Info("Set user rules") - return cl.doPost(cl.client.R().EnableTrace().SetBody(rules.ToPayload(cl.version)), "/filtering/set_rules") +func (cl *client) SetCustomRules(rules *[]string) error { + cl.log.With("rules", len(*rules)).Info("Set user rules") + return cl.doPost(cl.client.R().EnableTrace().SetBody(&model.SetRulesRequest{Rules: rules}), "/filtering/set_rules") } -func (cl *client) ToggleFiltering(enabled bool, interval float64) error { +func (cl *client) ToggleFiltering(enabled bool, interval int) error { cl.log.With("enabled", enabled, "interval", interval).Info("Toggle filtering") - return cl.doPost(cl.client.R().EnableTrace().SetBody(&types.FilteringConfig{ - EnableConfig: types.EnableConfig{Enabled: enabled}, - IntervalConfig: types.IntervalConfig{Interval: interval}, + return cl.doPost(cl.client.R().EnableTrace().SetBody(&model.FilterConfig{ + Enabled: utils.Ptr(enabled), + Interval: utils.Ptr(interval), }), "/filtering/config") } -func (cl *client) Services() (types.Services, error) { - svcs := types.Services{} - err := cl.doGet(cl.client.R().EnableTrace().SetResult(&svcs), "/blocked_services/list") +func (cl *client) BlockedServices() (*model.BlockedServicesArray, error) { + svcs := &model.BlockedServicesArray{} + err := cl.doGet(cl.client.R().EnableTrace().SetResult(svcs), "/blocked_services/list") return svcs, err } -func (cl *client) SetServices(services types.Services) error { - cl.log.With("services", len(services)).Info("Set services") - return cl.doPost(cl.client.R().EnableTrace().SetBody(&services), "/blocked_services/set") +func (cl *client) SetBlockedServices(services *model.BlockedServicesArray) error { + cl.log.With("services", model.ArrayString(services)).Info("Set blocked services") + return cl.doPost(cl.client.R().EnableTrace().SetBody(services), "/blocked_services/set") } -func (cl *client) Clients() (*types.Clients, error) { - clients := &types.Clients{} +func (cl *client) BlockedServicesSchedule() (*model.BlockedServicesSchedule, error) { + sched := &model.BlockedServicesSchedule{} + err := cl.doGet(cl.client.R().EnableTrace().SetResult(sched), "/blocked_services/get") + return sched, err +} + +func (cl *client) SetBlockedServicesSchedule(schedule *model.BlockedServicesSchedule) error { + cl.log.With("services", schedule.ServicesString()).Info("Set blocked services schedule") + return cl.doPut(cl.client.R().EnableTrace().SetBody(schedule), "/blocked_services/update") +} + +func (cl *client) Clients() (*model.Clients, error) { + clients := &model.Clients{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(clients), "/clients") return clients, err } -func (cl *client) AddClients(clients ...types.Client) error { +func (cl *client) AddClients(clients ...*model.Client) error { for i := range clients { client := clients[i] - cl.log.With("name", client.Name).Info("Add client") - err := cl.doPost(cl.client.R().EnableTrace().SetBody(&client), "/clients/add") + cl.log.With("name", *client.Name).Info("Add client") + err := cl.doPost(cl.client.R().EnableTrace().SetBody(client), "/clients/add") if err != nil { return err } @@ -372,10 +331,10 @@ func (cl *client) AddClients(clients ...types.Client) error { return nil } -func (cl *client) UpdateClients(clients ...types.Client) error { +func (cl *client) UpdateClients(clients ...*model.Client) error { for _, client := range clients { - cl.log.With("name", client.Name).Info("Update client") - err := cl.doPost(cl.client.R().EnableTrace().SetBody(&types.ClientUpdate{Name: client.Name, Data: client}), "/clients/update") + cl.log.With("name", *client.Name).Info("Update client") + err := cl.doPost(cl.client.R().EnableTrace().SetBody(&model.ClientUpdate{Name: client.Name, Data: client}), "/clients/update") if err != nil { return err } @@ -383,11 +342,11 @@ func (cl *client) UpdateClients(clients ...types.Client) error { return nil } -func (cl *client) DeleteClients(clients ...types.Client) error { +func (cl *client) DeleteClients(clients ...*model.Client) error { for i := range clients { client := clients[i] - cl.log.With("name", client.Name).Info("Delete client") - err := cl.doPost(cl.client.R().EnableTrace().SetBody(&client), "/clients/delete") + cl.log.With("name", *client.Name).Info("Delete client") + err := cl.doPost(cl.client.R().EnableTrace().SetBody(client), "/clients/delete") if err != nil { return err } @@ -395,30 +354,26 @@ func (cl *client) DeleteClients(clients ...types.Client) error { return nil } -func (cl *client) QueryLogConfig() (*types.QueryLogConfig, error) { - qlc := &types.QueryLogConfig{} +func (cl *client) QueryLogConfig() (*model.QueryLogConfig, error) { + qlc := &model.QueryLogConfig{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(qlc), "/querylog_info") return qlc, err } -func (cl *client) SetQueryLogConfig(enabled bool, interval float64, anonymizeClientIP bool) error { - cl.log.With("enabled", enabled, "interval", interval, "anonymizeClientIP", anonymizeClientIP).Info("Set query log config") - return cl.doPost(cl.client.R().EnableTrace().SetBody(&types.QueryLogConfig{ - EnableConfig: types.EnableConfig{Enabled: enabled}, - IntervalConfig: types.IntervalConfig{Interval: interval}, - AnonymizeClientIP: anonymizeClientIP, - }), "/querylog_config") +func (cl *client) SetQueryLogConfig(qlc *model.QueryLogConfig) error { + cl.log.With("enabled", *qlc.Enabled, "interval", *qlc.Interval, "anonymizeClientIP", *qlc.AnonymizeClientIp).Info("Set query log config") + return cl.doPost(cl.client.R().EnableTrace().SetBody(qlc), "/querylog_config") } -func (cl *client) StatsConfig() (*types.IntervalConfig, error) { - stats := &types.IntervalConfig{} +func (cl *client) StatsConfig() (*model.StatsConfig, error) { + stats := &model.StatsConfig{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(stats), "/stats_info") return stats, err } -func (cl *client) SetStatsConfig(interval float64) error { - cl.log.With("interval", interval).Info("Set stats config") - return cl.doPost(cl.client.R().EnableTrace().SetBody(&types.IntervalConfig{Interval: interval}), "/stats_config") +func (cl *client) SetStatsConfig(sc *model.StatsConfig) error { + cl.log.With("interval", *sc.Interval).Info("Set stats config") + return cl.doPost(cl.client.R().EnableTrace().SetBody(sc), "/stats_config") } func (cl *client) Setup() error { @@ -447,42 +402,42 @@ func (cl *client) Setup() error { return cl.doPost(req, "/install/configure") } -func (cl *client) AccessList() (*types.AccessList, error) { - al := &types.AccessList{} +func (cl *client) AccessList() (*model.AccessList, error) { + al := &model.AccessList{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(al), "/access/list") return al, err } -func (cl *client) SetAccessList(list *types.AccessList) error { +func (cl *client) SetAccessList(list *model.AccessList) error { cl.log.Info("Set access list") return cl.doPost(cl.client.R().EnableTrace().SetBody(list), "/access/set") } -func (cl *client) DNSConfig() (*types.DNSConfig, error) { - cfg := &types.DNSConfig{} +func (cl *client) DNSConfig() (*model.DNSConfig, error) { + cfg := &model.DNSConfig{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(cfg), "/dns_info") return cfg, err } -func (cl *client) SetDNSConfig(config *types.DNSConfig) error { +func (cl *client) SetDNSConfig(config *model.DNSConfig) error { cl.log.Info("Set dns config list") return cl.doPost(cl.client.R().EnableTrace().SetBody(config), "/dns_config") } -func (cl *client) DHCPServerConfig() (*types.DHCPServerConfig, error) { - cfg := &types.DHCPServerConfig{} +func (cl *client) DhcpConfig() (*model.DhcpStatus, error) { + cfg := &model.DhcpStatus{} err := cl.doGet(cl.client.R().EnableTrace().SetResult(cfg), "/dhcp/status") return cfg, err } -func (cl *client) SetDHCPServerConfig(config *types.DHCPServerConfig) error { +func (cl *client) SetDhcpConfig(config *model.DhcpStatus) error { cl.log.Info("Set dhcp server config") return cl.doPost(cl.client.R().EnableTrace().SetBody(config), "/dhcp/set_config") } -func (cl *client) AddDHCPStaticLeases(leases ...types.Lease) error { +func (cl *client) AddDHCPStaticLeases(leases ...model.DhcpStaticLease) error { for _, l := range leases { - cl.log.With("mac", l.HWAddr, "ip", l.IP, "hostname", l.Hostname).Info("Add static dhcp lease") + cl.log.With("mac", l.Mac, "ip", l.Ip, "hostname", l.Hostname).Info("Add static dhcp lease") err := cl.doPost(cl.client.R().EnableTrace().SetBody(l), "/dhcp/add_static_lease") if err != nil { return err @@ -491,9 +446,9 @@ func (cl *client) AddDHCPStaticLeases(leases ...types.Lease) error { return nil } -func (cl *client) DeleteDHCPStaticLeases(leases ...types.Lease) error { +func (cl *client) DeleteDHCPStaticLeases(leases ...model.DhcpStaticLease) error { for _, l := range leases { - cl.log.With("mac", l.HWAddr, "ip", l.IP, "hostname", l.Hostname).Info("Delete static dhcp lease") + cl.log.With("mac", l.Mac, "ip", l.Ip, "hostname", l.Hostname).Info("Delete static dhcp lease") err := cl.doPost(cl.client.R().EnableTrace().SetBody(l), "/dhcp/remove_static_lease") if err != nil { return err @@ -501,3 +456,25 @@ func (cl *client) DeleteDHCPStaticLeases(leases ...types.Lease) error { } return nil } + +func (cl *client) SafeSearchConfig() (*model.SafeSearchConfig, error) { + sss := &model.SafeSearchConfig{} + err := cl.doGet(cl.client.R().EnableTrace().SetResult(sss), "/safesearch/status") + return sss, err +} + +func (cl *client) SetSafeSearchConfig(settings *model.SafeSearchConfig) error { + cl.log.With("enabled", *settings.Enabled).Info("Set safesearch settings") + return cl.doPut(cl.client.R().EnableTrace().SetBody(settings), "/safesearch/settings") +} + +func (cl *client) ProfileInfo() (*model.ProfileInfo, error) { + p := &model.ProfileInfo{} + err := cl.doGet(cl.client.R().EnableTrace().SetResult(p), "/profile") + return p, err +} + +func (cl *client) SetProfileInfo(profile *model.ProfileInfo) error { + cl.log.With("language", profile.Language, "theme", profile.Theme).Info("Set profile") + return cl.doPut(cl.client.R().EnableTrace().SetBody(profile), "/profile/update") +} diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 21dcde9..ade963d 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -9,7 +9,9 @@ import ( "path/filepath" "github.com/bakito/adguardhome-sync/pkg/client" + "github.com/bakito/adguardhome-sync/pkg/client/model" "github.com/bakito/adguardhome-sync/pkg/types" + "github.com/bakito/adguardhome-sync/pkg/utils" "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -39,13 +41,13 @@ var _ = Describe("Client", func() { }) }) - Context("Filtering", func() { - It("should read filtering status", func() { + Context("Filter", func() { + It("should read filter status", func() { ts, cl = ClientGet("filtering-status.json", "/filtering/status") fs, err := cl.Filtering() Ω(err).ShouldNot(HaveOccurred()) - Ω(fs.Enabled).Should(BeTrue()) - Ω(fs.Filters).Should(HaveLen(2)) + Ω(*fs.Enabled).Should(BeTrue()) + Ω(*fs.Filters).Should(HaveLen(2)) }) It("should enable protection", func() { ts, cl = ClientPost("/filtering/config", `{"enabled":true,"interval":123}`) @@ -64,35 +66,26 @@ var _ = Describe("Client", func() { }) It("should add Filters", func() { ts, cl = ClientPost("/filtering/add_url", - `{"id":0,"enabled":false,"url":"foo","name":"","rules_count":0,"whitelist":true}`, - `{"id":0,"enabled":false,"url":"bar","name":"","rules_count":0,"whitelist":true}`, + `{"name":"","url":"foo","whitelist":true}`, + `{"name":"","url":"bar","whitelist":true}`, ) - err := cl.AddFilters(true, types.Filter{URL: "foo"}, types.Filter{URL: "bar"}) + err := cl.AddFilters(true, model.Filter{Url: "foo"}, model.Filter{Url: "bar"}) Ω(err).ShouldNot(HaveOccurred()) }) It("should update Filters", func() { ts, cl = ClientPost("/filtering/set_url", - `{"url":"foo","data":{"id":0,"enabled":false,"url":"foo","name":"","rules_count":0,"whitelist":true},"whitelist":true}`, - `{"url":"bar","data":{"id":0,"enabled":false,"url":"bar","name":"","rules_count":0,"whitelist":true},"whitelist":true}`, + `{"data":{"enabled":false,"name":"","url":"foo"},"url":"foo","whitelist":true}`, + `{"data":{"enabled":false,"name":"","url":"bar"},"url":"bar","whitelist":true}`, ) - err := cl.UpdateFilters(true, types.Filter{URL: "foo"}, types.Filter{URL: "bar"}) + err := cl.UpdateFilters(true, model.Filter{Url: "foo"}, model.Filter{Url: "bar"}) Ω(err).ShouldNot(HaveOccurred()) }) It("should delete Filters", func() { ts, cl = ClientPost("/filtering/remove_url", - `{"id":0,"enabled":false,"url":"foo","name":"","rules_count":0,"whitelist":true}`, - `{"id":0,"enabled":false,"url":"bar","name":"","rules_count":0,"whitelist":true}`, + `{"url":"foo","whitelist":true}`, + `{"url":"bar","whitelist":true}`, ) - err := cl.DeleteFilters(true, types.Filter{URL: "foo"}, types.Filter{URL: "bar"}) - Ω(err).ShouldNot(HaveOccurred()) - }) - }) - - Context("CustomRules", func() { - It("should set SetCustomRules", func() { - ts, cl = ClientPost("/filtering/set_rules", `foo -bar`) - err := cl.SetCustomRules([]string{"foo", "bar"}) + err := cl.DeleteFilters(true, model.Filter{Url: "foo"}, model.Filter{Url: "bar"}) Ω(err).ShouldNot(HaveOccurred()) }) }) @@ -102,8 +95,8 @@ bar`) ts, cl = ClientGet("status.json", "/status") fs, err := cl.Status() Ω(err).ShouldNot(HaveOccurred()) - Ω(fs.DNSAddresses).Should(HaveLen(1)) - Ω(fs.DNSAddresses[0]).Should(Equal("192.168.1.2")) + Ω(fs.DnsAddresses).Should(HaveLen(1)) + Ω(fs.DnsAddresses[0]).Should(Equal("192.168.1.2")) Ω(fs.Version).Should(Equal("v0.105.2")) }) It("should return ErrSetupNeeded", func() { @@ -135,13 +128,19 @@ bar`) Ω(*rwl).Should(HaveLen(2)) }) It("should add RewriteList", func() { - ts, cl = ClientPost("/rewrite/add", `{"domain":"foo","answer":"foo"}`, `{"domain":"bar","answer":"bar"}`) - err := cl.AddRewriteEntries(types.RewriteEntry{Answer: "foo", Domain: "foo"}, types.RewriteEntry{Answer: "bar", Domain: "bar"}) + ts, cl = ClientPost("/rewrite/add", `{"answer":"foo","domain":"foo"}`, `{"answer":"bar","domain":"bar"}`) + err := cl.AddRewriteEntries( + model.RewriteEntry{Answer: utils.Ptr("foo"), Domain: utils.Ptr("foo")}, + model.RewriteEntry{Answer: utils.Ptr("bar"), Domain: utils.Ptr("bar")}, + ) Ω(err).ShouldNot(HaveOccurred()) }) It("should delete RewriteList", func() { - ts, cl = ClientPost("/rewrite/delete", `{"domain":"foo","answer":"foo"}`, `{"domain":"bar","answer":"bar"}`) - err := cl.DeleteRewriteEntries(types.RewriteEntry{Answer: "foo", Domain: "foo"}, types.RewriteEntry{Answer: "bar", Domain: "bar"}) + ts, cl = ClientPost("/rewrite/delete", `{"answer":"foo","domain":"foo"}`, `{"answer":"bar","domain":"bar"}`) + err := cl.DeleteRewriteEntries( + model.RewriteEntry{Answer: utils.Ptr("foo"), Domain: utils.Ptr("foo")}, + model.RewriteEntry{Answer: utils.Ptr("bar"), Domain: utils.Ptr("bar")}, + ) Ω(err).ShouldNot(HaveOccurred()) }) }) @@ -165,21 +164,22 @@ bar`) }) }) - Context("SafeSearch", func() { + Context("SafeSearchConfig", func() { It("should read safesearch status", func() { ts, cl = ClientGet("safesearch-status.json", "/safesearch/status") - ss, err := cl.SafeSearch() + ss, err := cl.SafeSearchConfig() Ω(err).ShouldNot(HaveOccurred()) - Ω(ss).Should(BeTrue()) + Ω(ss.Enabled).ShouldNot(BeNil()) + Ω(*ss.Enabled).Should(BeTrue()) }) It("should enable safesearch", func() { - ts, cl = ClientPost("/safesearch/enable", "") - err := cl.ToggleSafeSearch(true) + ts, cl = ClientPut("/safesearch/settings", `{"enabled":true}`) + err := cl.SetSafeSearchConfig(&model.SafeSearchConfig{Enabled: utils.Ptr(true)}) Ω(err).ShouldNot(HaveOccurred()) }) It("should disable safesearch", func() { - ts, cl = ClientPost("/safesearch/disable", "") - err := cl.ToggleSafeSearch(false) + ts, cl = ClientPut("/safesearch/settings", `{"enabled":false}`) + err := cl.SetSafeSearchConfig(&model.SafeSearchConfig{Enabled: utils.Ptr(false)}) Ω(err).ShouldNot(HaveOccurred()) }) }) @@ -216,16 +216,39 @@ bar`) }) }) - Context("Services", func() { - It("should read Services", func() { + Context("BlockedServices", func() { + It("should read BlockedServices", func() { ts, cl = ClientGet("blockedservices-list.json", "/blocked_services/list") - s, err := cl.Services() + s, err := cl.BlockedServices() Ω(err).ShouldNot(HaveOccurred()) - Ω(s).Should(HaveLen(2)) + Ω(*s).Should(HaveLen(2)) }) - It("should set Services", func() { - ts, cl = ClientPost("/blocked_services/set", `["foo","bar"]`) - err := cl.SetServices([]string{"foo", "bar"}) + It("should set BlockedServices", func() { + ts, cl = ClientPost("/blocked_services/set", `["bar","foo"]`) + err := cl.SetBlockedServices(&model.BlockedServicesArray{"foo", "bar"}) + Ω(err).ShouldNot(HaveOccurred()) + }) + }) + + Context("BlockedServicesSchedule", func() { + It("should read BlockedServicesSchedule", func() { + ts, cl = ClientGet("blockedservicesschedule-get.json", "/blocked_services/get") + s, err := cl.BlockedServicesSchedule() + Ω(err).ShouldNot(HaveOccurred()) + Ω(*s.Ids).Should(HaveLen(3)) + }) + It("should set BlockedServicesSchedule", func() { + ts, cl = ClientPost("/blocked_services/update", + `{"ids":["bar","foo"],"schedule":{"mon":{"end":99,"start":1}}}`) + err := cl.SetBlockedServicesSchedule(&model.BlockedServicesSchedule{ + Ids: utils.Ptr([]string{"foo", "bar"}), + Schedule: &model.Schedule{ + Mon: &model.DayRange{ + Start: utils.Ptr(float32(1.0)), + End: utils.Ptr(float32(99.0)), + }, + }, + }) Ω(err).ShouldNot(HaveOccurred()) }) }) @@ -235,27 +258,27 @@ bar`) ts, cl = ClientGet("clients.json", "/clients") c, err := cl.Clients() Ω(err).ShouldNot(HaveOccurred()) - Ω(c.Clients).Should(HaveLen(2)) + Ω(*c.Clients).Should(HaveLen(2)) }) It("should add Clients", func() { ts, cl = ClientPost("/clients/add", - `{"ids":["id"],"use_global_settings":false,"use_global_blocked_services":false,"name":"foo","filtering_enabled":false,"parental_enabled":false,"safesearch_enabled":false,"safebrowsing_enabled":false,"disallowed":false,"disallowed_rule":""}`, + `{"ids":["id"],"name":"foo"}`, ) - err := cl.AddClients(types.Client{Name: "foo", Ids: []string{"id"}}) + err := cl.AddClients(&model.Client{Name: utils.Ptr("foo"), Ids: utils.Ptr([]string{"id"})}) Ω(err).ShouldNot(HaveOccurred()) }) It("should update Clients", func() { ts, cl = ClientPost("/clients/update", - `{"name":"foo","data":{"ids":["id"],"use_global_settings":false,"use_global_blocked_services":false,"name":"foo","filtering_enabled":false,"parental_enabled":false,"safesearch_enabled":false,"safebrowsing_enabled":false,"disallowed":false,"disallowed_rule":""}}`, + `{"data":{"ids":["id"],"name":"foo"},"name":"foo"}`, ) - err := cl.UpdateClients(types.Client{Name: "foo", Ids: []string{"id"}}) + err := cl.UpdateClients(&model.Client{Name: utils.Ptr("foo"), Ids: utils.Ptr([]string{"id"})}) Ω(err).ShouldNot(HaveOccurred()) }) It("should delete Clients", func() { ts, cl = ClientPost("/clients/delete", - `{"ids":["id"],"use_global_settings":false,"use_global_blocked_services":false,"name":"foo","filtering_enabled":false,"parental_enabled":false,"safesearch_enabled":false,"safebrowsing_enabled":false,"disallowed":false,"disallowed_rule":""}`, + `{"ids":["id"],"name":"foo"}`, ) - err := cl.DeleteClients(types.Client{Name: "foo", Ids: []string{"id"}}) + err := cl.DeleteClients(&model.Client{Name: utils.Ptr("foo"), Ids: utils.Ptr([]string{"id"})}) Ω(err).ShouldNot(HaveOccurred()) }) }) @@ -265,12 +288,16 @@ bar`) ts, cl = ClientGet("querylog_info.json", "/querylog_info") qlc, err := cl.QueryLogConfig() Ω(err).ShouldNot(HaveOccurred()) - Ω(qlc.Enabled).Should(BeTrue()) - Ω(qlc.Interval).Should(Equal(90.0)) + Ω(qlc.Enabled).ShouldNot(BeNil()) + Ω(*qlc.Enabled).Should(BeTrue()) + Ω(qlc.Interval).ShouldNot(BeNil()) + Ω(*qlc.Interval).Should(Equal(model.QueryLogConfigInterval(90))) }) It("should set QueryLogConfig", func() { - ts, cl = ClientPost("/querylog_config", `{"enabled":true,"interval":123,"anonymize_client_ip":true}`) - err := cl.SetQueryLogConfig(true, 123, true) + ts, cl = ClientPost("/querylog_config", `{"anonymize_client_ip":true,"enabled":true,"interval":123}`) + + var interval model.QueryLogConfigInterval = 123 + err := cl.SetQueryLogConfig(&model.QueryLogConfig{AnonymizeClientIp: utils.Ptr(true), Interval: &interval, Enabled: utils.Ptr(true)}) Ω(err).ShouldNot(HaveOccurred()) }) }) @@ -279,11 +306,14 @@ bar`) ts, cl = ClientGet("stats_info.json", "/stats_info") sc, err := cl.StatsConfig() Ω(err).ShouldNot(HaveOccurred()) - Ω(sc.Interval).Should(Equal(1.0)) + Ω(sc.Interval).ShouldNot(BeNil()) + Ω(*sc.Interval).Should(Equal(model.StatsConfigInterval(1))) }) It("should set StatsConfig", func() { ts, cl = ClientPost("/stats_config", `{"interval":123}`) - err := cl.SetStatsConfig(123.0) + + var interval model.StatsConfigInterval = 123 + err := cl.SetStatsConfig(&model.StatsConfig{Interval: &interval}) Ω(err).ShouldNot(HaveOccurred()) }) }) @@ -308,7 +338,8 @@ bar`) Context("doPost", func() { It("should return an error on status code != 200", func() { - err := cl.SetStatsConfig(123) + var interval model.StatsConfigInterval = 123 + err := cl.SetStatsConfig(&model.StatsConfig{Interval: &interval}) Ω(err).Should(HaveOccurred()) Ω(err.Error()).Should(Equal("401 Unauthorized")) }) @@ -344,3 +375,18 @@ func ClientPost(path string, content ...string) (*httptest.Server, client.Client Ω(err).ShouldNot(HaveOccurred()) return ts, cl } + +func ClientPut(path string, content ...string) (*httptest.Server, client.Client) { + index := 0 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + Ω(r.URL.Path).Should(Equal(types.DefaultAPIPath + path)) + body, err := io.ReadAll(r.Body) + Ω(err).ShouldNot(HaveOccurred()) + Ω(body).Should(Equal([]byte(content[index]))) + index++ + })) + + cl, err := client.New(types.AdGuardInstance{URL: ts.URL, Username: username, Password: password}) + Ω(err).ShouldNot(HaveOccurred()) + return ts, cl +} diff --git a/pkg/client/model/client/client.go b/pkg/client/model/client/client.go new file mode 100644 index 0000000..ec80d4d --- /dev/null +++ b/pkg/client/model/client/client.go @@ -0,0 +1,144 @@ +package client + +import ( + "context" + "crypto/tls" + "encoding/base64" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "path" + + "github.com/bakito/adguardhome-sync/pkg/client/model" + "github.com/bakito/adguardhome-sync/pkg/log" + "github.com/bakito/adguardhome-sync/pkg/types" + "go.uber.org/zap" +) + +var l = log.GetLogger("client") + +// New create a new api client +func New(config types.AdGuardInstance) (Client, error) { + var apiURL string + if config.APIPath == "" { + apiURL = fmt.Sprintf("%s/control", config.URL) + } else { + apiURL = fmt.Sprintf("%s/%s", config.URL, config.APIPath) + } + u, err := url.Parse(apiURL) + if err != nil { + return nil, err + } + u.Path = path.Clean(u.Path) + + httpClient := &http.Client{} + if config.InsecureSkipVerify { + // #nosec G402 has to be explicitly enabled + httpClient.Transport = &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + } + + aghClient, err := model.NewClient(u.String(), func(client *model.AdguardHomeClient) error { + client.Client = httpClient + client.RequestEditors = append(client.RequestEditors, func(ctx context.Context, req *http.Request) error { + if config.Username != "" && config.Password != "" { + req.Header.Add("Authorization", "Basic "+basicAuth(config.Username, config.Password)) + } + return nil + }) + return nil + }) + if err != nil { + return nil, err + } + + return &apiClient{ + host: u.Host, + client: aghClient, + log: l.With("host", u.Host), + }, nil +} + +func basicAuth(username, password string) string { + auth := username + ":" + password + return base64.StdEncoding.EncodeToString([]byte(auth)) +} + +type apiClient struct { + host string + client *model.AdguardHomeClient + log *zap.SugaredLogger +} + +func (a apiClient) Host(context.Context) string { + return a.host +} + +func (a apiClient) GetServerStatus(ctx context.Context) (*model.ServerStatus, error) { + sr, err := read(ctx, a.client.Status, model.ParseStatusResp) + if err != nil { + return nil, err + } + return sr.JSON200, nil +} + +func (a apiClient) GetFilteringStatus(ctx context.Context) (*model.FilterStatus, error) { + sr, err := read(ctx, a.client.FilteringStatus, model.ParseFilteringStatusResp) + if err != nil { + return nil, err + } + return sr.JSON200, nil +} + +func (a apiClient) SetFilteringConfig(ctx context.Context, config model.FilterConfig) error { + return write(ctx, config, a.client.FilteringConfig) +} + +func write[B interface{}]( + ctx context.Context, + body B, + req func(ctx context.Context, body B, reqEditors ...model.RequestEditorFn) (*http.Response, error), +) error { + resp, err := req(ctx, body) + if err != nil { + return err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return detailedError(resp) + } + return nil +} + +func read[I interface{}]( + ctx context.Context, + req func(ctx context.Context, reqEditors ...model.RequestEditorFn) (*http.Response, error), + parse func(rsp *http.Response) (*I, error), +) (*I, error) { + resp, err := req(ctx) + if err != nil { + return nil, err + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil, detailedError(resp) + } + return parse(resp) +} + +func detailedError(resp *http.Response) error { + e := resp.Status + + body, err := io.ReadAll(resp.Body) + if err != nil { + return err + } + + if len(body) > 0 { + e += fmt.Sprintf("(%s)", string(body)) + } + return errors.New(e) +} diff --git a/pkg/client/model/client/interface.go b/pkg/client/model/client/interface.go new file mode 100644 index 0000000..3ad23c4 --- /dev/null +++ b/pkg/client/model/client/interface.go @@ -0,0 +1,15 @@ +package client + +import ( + "context" + + "github.com/bakito/adguardhome-sync/pkg/client/model" +) + +type Client interface { + Host(ctx context.Context) string + GetServerStatus(ctx context.Context) (*model.ServerStatus, error) + + GetFilteringStatus(ctx context.Context) (*model.FilterStatus, error) + SetFilteringConfig(ctx context.Context, config model.FilterConfig) error +} diff --git a/pkg/client/model/client/resty.go b/pkg/client/model/client/resty.go new file mode 100644 index 0000000..3341bfb --- /dev/null +++ b/pkg/client/model/client/resty.go @@ -0,0 +1,27 @@ +package client + +import ( + "net/http" + + "github.com/bakito/adguardhome-sync/pkg/client/model" + "github.com/go-resty/resty/v2" +) + +var _ model.HttpRequestDoer = &adapter{} + +func RestyAdapter(r *resty.Client) model.HttpRequestDoer { + return &adapter{ + client: r, + } +} + +type adapter struct { + client *resty.Client +} + +func (a adapter) Do(req *http.Request) (*http.Response, error) { + r, err := a.client.R(). + SetHeaderMultiValues(req.Header). + Execute(req.Method, req.URL.String()) + return r.RawResponse, err +} diff --git a/pkg/client/model/model-functions.go b/pkg/client/model/model-functions.go new file mode 100644 index 0000000..18d41e8 --- /dev/null +++ b/pkg/client/model/model-functions.go @@ -0,0 +1,372 @@ +package model + +import ( + "fmt" + "sort" + "strings" + + "github.com/bakito/adguardhome-sync/pkg/utils" + "github.com/jinzhu/copier" +) + +// Clone the config +func (c *DhcpStatus) Clone() *DhcpStatus { + clone := &DhcpStatus{} + _ = copier.Copy(clone, c) + return clone +} + +// Equals dhcp server config equal check +func (c *DhcpStatus) Equals(o *DhcpStatus) bool { + return utils.JsonEquals(c, o) +} + +func (c *DhcpStatus) HasConfig() bool { + return (c.V4 != nil && c.V4.isValid()) || (c.V6 != nil && c.V6.isValid()) +} + +func (j DhcpConfigV4) isValid() bool { + return j.GatewayIp != nil && j.SubnetMask != nil && j.RangeStart != nil && j.RangeEnd != nil +} + +func (j DhcpConfigV6) isValid() bool { + return j.RangeStart != nil +} + +type DhcpStaticLeases []DhcpStaticLease + +// MergeDhcpStaticLeases the leases +func MergeDhcpStaticLeases(l *[]DhcpStaticLease, other *[]DhcpStaticLease) (DhcpStaticLeases, DhcpStaticLeases) { + var thisLeases []DhcpStaticLease + var otherLeases []DhcpStaticLease + + if l != nil { + thisLeases = *l + } + if other != nil { + otherLeases = *other + } + current := make(map[string]DhcpStaticLease) + + var adds DhcpStaticLeases + var removes DhcpStaticLeases + for _, le := range thisLeases { + current[le.Mac] = le + } + + for _, le := range otherLeases { + if _, ok := current[le.Mac]; ok { + delete(current, le.Mac) + } else { + adds = append(adds, le) + } + } + + for _, rr := range current { + removes = append(removes, rr) + } + + return adds, removes +} + +// Equals dns config equal check +func (c *DNSConfig) Equals(o *DNSConfig) bool { + cc := c.Clone() + oo := o.Clone() + cc.Sort() + oo.Sort() + + return utils.JsonEquals(cc, oo) +} + +func (c *DNSConfig) Clone() *DNSConfig { + return utils.Clone(c, &DNSConfig{}) +} + +// Sort sort dns config +func (c *DNSConfig) Sort() { + if c.UpstreamDns != nil { + sort.Strings(*c.UpstreamDns) + } + + if c.UpstreamDns != nil { + sort.Strings(*c.BootstrapDns) + } + + if c.UpstreamDns != nil { + sort.Strings(*c.LocalPtrUpstreams) + } +} + +// Equals access list equal check +func (al *AccessList) Equals(o *AccessList) bool { + return EqualsStringSlice(al.AllowedClients, o.AllowedClients, true) && + EqualsStringSlice(al.DisallowedClients, o.DisallowedClients, true) && + EqualsStringSlice(al.BlockedHosts, o.BlockedHosts, true) +} + +func EqualsStringSlice(a *[]string, b *[]string, sortIt bool) bool { + if a == nil && b == nil { + return true + } + + if a == nil || b == nil { + return false + } + + aa := *a + bb := *b + if sortIt { + sort.Strings(aa) + sort.Strings(bb) + } + if len(aa) != len(bb) { + return false + } + for i, v := range aa { + if v != bb[i] { + return false + } + } + return true +} + +// Sort clients +func (cl *Client) Sort() { + if cl.Ids != nil { + sort.Strings(*cl.Ids) + } + if cl.Tags != nil { + sort.Strings(*cl.Tags) + } + if cl.BlockedServices != nil { + sort.Strings(*cl.BlockedServices) + } + if cl.Upstreams != nil { + sort.Strings(*cl.Upstreams) + } +} + +// Equals Clients equal check +func (cl *Client) Equals(o *Client) bool { + cl.Sort() + o.Sort() + + return utils.JsonEquals(cl, o) +} + +// Add ac client +func (clients *Clients) Add(cl Client) { + if clients.Clients == nil { + clients.Clients = &ClientsArray{cl} + } else { + a := append(*clients.Clients, cl) + clients.Clients = &a + } +} + +// Merge merge Clients +func (clients *Clients) Merge(other *Clients) ([]*Client, []*Client, []*Client) { + current := make(map[string]*Client) + if clients.Clients != nil { + cc := *clients.Clients + for i := range cc { + client := cc[i] + current[*client.Name] = &client + } + } + + expected := make(map[string]*Client) + if other.Clients != nil { + oc := *other.Clients + for i := range oc { + client := oc[i] + expected[*client.Name] = &client + } + } + + var adds []*Client + var removes []*Client + var updates []*Client + + for _, cl := range expected { + if oc, ok := current[*cl.Name]; ok { + if !cl.Equals(oc) { + updates = append(updates, cl) + } + delete(current, *cl.Name) + } else { + adds = append(adds, cl) + } + } + + for _, rr := range current { + removes = append(removes, rr) + } + + return adds, updates, removes +} + +// Key RewriteEntry key +func (re *RewriteEntry) Key() string { + var d string + var a string + if re.Domain != nil { + d = *re.Domain + } + if re.Answer != nil { + a = *re.Answer + } + return fmt.Sprintf("%s#%s", d, a) +} + +// RewriteEntries list of RewriteEntry +type RewriteEntries []RewriteEntry + +// Merge RewriteEntries +func (rwe *RewriteEntries) Merge(other *RewriteEntries) (RewriteEntries, RewriteEntries, RewriteEntries) { + current := make(map[string]RewriteEntry) + + var adds RewriteEntries + var removes RewriteEntries + var duplicates RewriteEntries + processed := make(map[string]bool) + for _, rr := range *rwe { + if _, ok := processed[rr.Key()]; !ok { + current[rr.Key()] = rr + processed[rr.Key()] = true + } else { + // remove duplicate + removes = append(removes, rr) + } + } + + for _, rr := range *other { + if _, ok := current[rr.Key()]; ok { + delete(current, rr.Key()) + } else { + if _, ok := processed[rr.Key()]; !ok { + adds = append(adds, rr) + processed[rr.Key()] = true + } else { + // skip duplicate + duplicates = append(duplicates, rr) + } + } + } + + for _, rr := range current { + removes = append(removes, rr) + } + + return adds, removes, duplicates +} + +func MergeFilters(this *[]Filter, other *[]Filter) ([]Filter, []Filter, []Filter) { + if this == nil && other == nil { + return nil, nil, nil + } + + current := make(map[string]*Filter) + + var adds []Filter + var updates []Filter + var removes []Filter + if this != nil { + for i := range *this { + fi := (*this)[i] + current[fi.Url] = &fi + } + } + + if other != nil { + for i := range *other { + rr := (*other)[i] + if c, ok := current[rr.Url]; ok { + if !c.Equals(&rr) { + updates = append(updates, rr) + } + delete(current, rr.Url) + } else { + adds = append(adds, rr) + } + } + } + + for _, rr := range current { + removes = append(removes, *rr) + } + + return adds, updates, removes +} + +// Equals Filter equal check +func (f *Filter) Equals(o *Filter) bool { + return f.Enabled == o.Enabled && f.Url == o.Url && f.Name == o.Name +} + +// Equals QueryLogConfig equal check +func (qlc *QueryLogConfig) Equals(o *QueryLogConfig) bool { + return ptrEquals(qlc.Enabled, o.Enabled) && + ptrEquals(qlc.AnonymizeClientIp, o.AnonymizeClientIp) && + qlc.Interval.Equals(o.Interval) +} + +// Equals QueryLogConfigInterval equal check +func (qlc *QueryLogConfigInterval) Equals(o *QueryLogConfigInterval) bool { + return ptrEquals(qlc, o) +} + +func ptrEquals[T comparable](a *T, b *T) bool { + if a == nil && b == nil { + return true + } + var aa T + if a != nil { + aa = *a + } + var bb T + if b != nil { + bb = *b + } + + return aa == bb +} + +// EnableConfig API struct +type EnableConfig struct { + Enabled bool `json:"enabled"` +} + +func (ssc *SafeSearchConfig) Equals(o *SafeSearchConfig) bool { + return ptrEquals(ssc.Enabled, o.Enabled) && + ptrEquals(ssc.Bing, o.Bing) && + ptrEquals(ssc.Duckduckgo, o.Duckduckgo) && + ptrEquals(ssc.Google, o.Google) && + ptrEquals(ssc.Pixabay, o.Pixabay) && + ptrEquals(ssc.Yandex, o.Yandex) && + ptrEquals(ssc.Youtube, o.Youtube) +} + +func (pi *ProfileInfo) Equals(o *ProfileInfo) bool { + return pi.Name == o.Name && + pi.Language == o.Language && + pi.Theme == o.Theme +} + +func (bss *BlockedServicesSchedule) Equals(o *BlockedServicesSchedule) bool { + return utils.JsonEquals(bss, o) +} + +func (bss *BlockedServicesSchedule) ServicesString() string { + return ArrayString(bss.Ids) +} + +func ArrayString(a *[]string) string { + if a == nil { + return "[]" + } + sorted := *a + sort.Strings(sorted) + return fmt.Sprintf("[%s]", strings.Join(sorted, ",")) +} diff --git a/pkg/client/model/model_generated.go b/pkg/client/model/model_generated.go new file mode 100644 index 0000000..b7aece0 --- /dev/null +++ b/pkg/client/model/model_generated.go @@ -0,0 +1,10566 @@ +// Package model provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT. +package model + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" + "time" + + "github.com/oapi-codegen/runtime" +) + +const ( + BasicAuthScopes = "basicAuth.Scopes" +) + +// Defines values for CheckConfigStaticIpInfoStatic. +const ( + CheckConfigStaticIpInfoStaticError CheckConfigStaticIpInfoStatic = "error" + CheckConfigStaticIpInfoStaticNo CheckConfigStaticIpInfoStatic = "no" + CheckConfigStaticIpInfoStaticYes CheckConfigStaticIpInfoStatic = "yes" +) + +// Defines values for DNSConfigBlockingMode. +const ( + CustomIp DNSConfigBlockingMode = "custom_ip" + Default DNSConfigBlockingMode = "default" + NullIp DNSConfigBlockingMode = "null_ip" + Nxdomain DNSConfigBlockingMode = "nxdomain" + Refused DNSConfigBlockingMode = "refused" +) + +// Defines values for DhcpSearchResultOtherServerFound. +const ( + DhcpSearchResultOtherServerFoundError DhcpSearchResultOtherServerFound = "error" + DhcpSearchResultOtherServerFoundNo DhcpSearchResultOtherServerFound = "no" + DhcpSearchResultOtherServerFoundYes DhcpSearchResultOtherServerFound = "yes" +) + +// Defines values for DhcpSearchResultStaticIPStatic. +const ( + DhcpSearchResultStaticIPStaticError DhcpSearchResultStaticIPStatic = "error" + DhcpSearchResultStaticIPStaticNo DhcpSearchResultStaticIPStatic = "no" + DhcpSearchResultStaticIPStaticYes DhcpSearchResultStaticIPStatic = "yes" +) + +// Defines values for FilterCheckHostResponseReason. +const ( + FilterCheckHostResponseReasonFilteredBlackList FilterCheckHostResponseReason = "FilteredBlackList" + FilterCheckHostResponseReasonFilteredBlockedService FilterCheckHostResponseReason = "FilteredBlockedService" + FilterCheckHostResponseReasonFilteredInvalid FilterCheckHostResponseReason = "FilteredInvalid" + FilterCheckHostResponseReasonFilteredParental FilterCheckHostResponseReason = "FilteredParental" + FilterCheckHostResponseReasonFilteredSafeBrowsing FilterCheckHostResponseReason = "FilteredSafeBrowsing" + FilterCheckHostResponseReasonFilteredSafeSearch FilterCheckHostResponseReason = "FilteredSafeSearch" + FilterCheckHostResponseReasonNotFilteredError FilterCheckHostResponseReason = "NotFilteredError" + FilterCheckHostResponseReasonNotFilteredNotFound FilterCheckHostResponseReason = "NotFilteredNotFound" + FilterCheckHostResponseReasonNotFilteredWhiteList FilterCheckHostResponseReason = "NotFilteredWhiteList" + FilterCheckHostResponseReasonRewrite FilterCheckHostResponseReason = "Rewrite" + FilterCheckHostResponseReasonRewriteEtcHosts FilterCheckHostResponseReason = "RewriteEtcHosts" + FilterCheckHostResponseReasonRewriteRule FilterCheckHostResponseReason = "RewriteRule" +) + +// Defines values for ProfileInfoTheme. +const ( + Auto ProfileInfoTheme = "auto" + Dark ProfileInfoTheme = "dark" + Light ProfileInfoTheme = "light" +) + +// Defines values for QueryLogConfigInterval. +const ( + QueryLogConfigIntervalN025 QueryLogConfigInterval = 0.25 + QueryLogConfigIntervalN1 QueryLogConfigInterval = 1 + QueryLogConfigIntervalN30 QueryLogConfigInterval = 30 + QueryLogConfigIntervalN7 QueryLogConfigInterval = 7 + QueryLogConfigIntervalN90 QueryLogConfigInterval = 90 +) + +// Defines values for QueryLogItemReason. +const ( + QueryLogItemReasonFilteredBlackList QueryLogItemReason = "FilteredBlackList" + QueryLogItemReasonFilteredBlockedService QueryLogItemReason = "FilteredBlockedService" + QueryLogItemReasonFilteredInvalid QueryLogItemReason = "FilteredInvalid" + QueryLogItemReasonFilteredParental QueryLogItemReason = "FilteredParental" + QueryLogItemReasonFilteredSafeBrowsing QueryLogItemReason = "FilteredSafeBrowsing" + QueryLogItemReasonFilteredSafeSearch QueryLogItemReason = "FilteredSafeSearch" + QueryLogItemReasonNotFilteredError QueryLogItemReason = "NotFilteredError" + QueryLogItemReasonNotFilteredNotFound QueryLogItemReason = "NotFilteredNotFound" + QueryLogItemReasonNotFilteredWhiteList QueryLogItemReason = "NotFilteredWhiteList" + QueryLogItemReasonRewrite QueryLogItemReason = "Rewrite" + QueryLogItemReasonRewriteEtcHosts QueryLogItemReason = "RewriteEtcHosts" + QueryLogItemReasonRewriteRule QueryLogItemReason = "RewriteRule" +) + +// Defines values for StatsTimeUnits. +const ( + Days StatsTimeUnits = "days" + Hours StatsTimeUnits = "hours" +) + +// Defines values for StatsConfigInterval. +const ( + StatsConfigIntervalN0 StatsConfigInterval = 0 + StatsConfigIntervalN1 StatsConfigInterval = 1 + StatsConfigIntervalN30 StatsConfigInterval = 30 + StatsConfigIntervalN7 StatsConfigInterval = 7 + StatsConfigIntervalN90 StatsConfigInterval = 90 +) + +// Defines values for TlsConfigKeyType. +const ( + ECDSA TlsConfigKeyType = "ECDSA" + RSA TlsConfigKeyType = "RSA" +) + +// Defines values for QueryLogParamsResponseStatus. +const ( + All QueryLogParamsResponseStatus = "all" + Blocked QueryLogParamsResponseStatus = "blocked" + BlockedParental QueryLogParamsResponseStatus = "blocked_parental" + BlockedSafebrowsing QueryLogParamsResponseStatus = "blocked_safebrowsing" + Filtered QueryLogParamsResponseStatus = "filtered" + Processed QueryLogParamsResponseStatus = "processed" + Rewritten QueryLogParamsResponseStatus = "rewritten" + SafeSearch QueryLogParamsResponseStatus = "safe_search" + Whitelisted QueryLogParamsResponseStatus = "whitelisted" +) + +// AccessList Client and host access list. Each of the lists should contain only unique elements. In addition, allowed and disallowed lists cannot contain the same elements. +type AccessList struct { + // AllowedClients The allowlist of clients: IP addresses, CIDRs, or ClientIDs. + AllowedClients *[]string `json:"allowed_clients,omitempty"` + + // BlockedHosts The blocklist of hosts. + BlockedHosts *[]string `json:"blocked_hosts,omitempty"` + + // DisallowedClients The blocklist of clients: IP addresses, CIDRs, or ClientIDs. + DisallowedClients *[]string `json:"disallowed_clients,omitempty"` +} + +// AccessListResponse Client and host access list. Each of the lists should contain only unique elements. In addition, allowed and disallowed lists cannot contain the same elements. +type AccessListResponse = AccessList + +// AccessSetRequest Client and host access list. Each of the lists should contain only unique elements. In addition, allowed and disallowed lists cannot contain the same elements. +type AccessSetRequest = AccessList + +// AddUrlRequest /add_url request data +type AddUrlRequest struct { + Name *string `json:"name,omitempty"` + + // Url URL or an absolute path to the file containing filtering rules. + Url *string `json:"url,omitempty"` + Whitelist *bool `json:"whitelist,omitempty"` +} + +// AddressInfo Port information +type AddressInfo struct { + Ip string `json:"ip"` + Port uint16 `json:"port"` +} + +// AddressesInfo AdGuard Home addresses configuration +type AddressesInfo struct { + DnsPort uint16 `json:"dns_port"` + + // Interfaces Network interfaces dictionary, keys are interface names. + Interfaces NetInterfaces `json:"interfaces"` + Version string `json:"version"` + WebPort uint16 `json:"web_port"` +} + +// BlockedService defines model for BlockedService. +type BlockedService struct { + // IconSvg The SVG icon as a Base64-encoded string to make it easier to embed it into a data URL. + IconSvg string `json:"icon_svg"` + + // Id The ID of this service. + Id string `json:"id"` + + // Name The human-readable name of this service. + Name string `json:"name"` + + // Rules The array of the filtering rules. + Rules []string `json:"rules"` +} + +// BlockedServicesAll defines model for BlockedServicesAll. +type BlockedServicesAll struct { + BlockedServices []BlockedService `json:"blocked_services"` +} + +// BlockedServicesArray defines model for BlockedServicesArray. +type BlockedServicesArray = []string + +// BlockedServicesSchedule defines model for BlockedServicesSchedule. +type BlockedServicesSchedule struct { + // Ids The names of the blocked services. + Ids *[]string `json:"ids,omitempty"` + + // Schedule Sets periods of inactivity for filtering blocked services. The schedule contains 7 days (Sunday to Saturday) and a time zone. + Schedule *Schedule `json:"schedule,omitempty"` +} + +// CheckConfigRequest Configuration to be checked +type CheckConfigRequest struct { + Dns *CheckConfigRequestInfo `json:"dns,omitempty"` + SetStaticIp *bool `json:"set_static_ip,omitempty"` + Web *CheckConfigRequestInfo `json:"web,omitempty"` +} + +// CheckConfigRequestInfo defines model for CheckConfigRequestInfo. +type CheckConfigRequestInfo struct { + Autofix *bool `json:"autofix,omitempty"` + Ip *string `json:"ip,omitempty"` + Port *uint16 `json:"port,omitempty"` +} + +// CheckConfigResponse defines model for CheckConfigResponse. +type CheckConfigResponse struct { + Dns CheckConfigResponseInfo `json:"dns"` + StaticIp CheckConfigStaticIpInfo `json:"static_ip"` + Web CheckConfigResponseInfo `json:"web"` +} + +// CheckConfigResponseInfo defines model for CheckConfigResponseInfo. +type CheckConfigResponseInfo struct { + CanAutofix bool `json:"can_autofix"` + Status string `json:"status"` +} + +// CheckConfigStaticIpInfo defines model for CheckConfigStaticIpInfo. +type CheckConfigStaticIpInfo struct { + // Error Error text. Set if static=error + Error *string `json:"error,omitempty"` + + // Ip Current dynamic IP address. Set if static=no + Ip *string `json:"ip,omitempty"` + + // Static Can be: yes, no, error + Static *CheckConfigStaticIpInfoStatic `json:"static,omitempty"` +} + +// CheckConfigStaticIpInfoStatic Can be: yes, no, error +type CheckConfigStaticIpInfoStatic string + +// Client Client information. +type Client struct { + BlockedServices *[]string `json:"blocked_services,omitempty"` + + // BlockedServicesSchedule Sets periods of inactivity for filtering blocked services. The schedule contains 7 days (Sunday to Saturday) and a time zone. + BlockedServicesSchedule *Schedule `json:"blocked_services_schedule,omitempty"` + FilteringEnabled *bool `json:"filtering_enabled,omitempty"` + + // Ids IP, CIDR, MAC, or ClientID. + Ids *[]string `json:"ids,omitempty"` + + // IgnoreQuerylog NOTE: If `ignore_querylog` is not set in HTTP API `GET /clients/add` + // request then default value (false) will be used. + // + // If `ignore_querylog` is not set in HTTP API `GET /clients/update` + // request then the existing value will not be changed. + // + // This behaviour can be changed in the future versions. + IgnoreQuerylog *bool `json:"ignore_querylog,omitempty"` + + // IgnoreStatistics NOTE: If `ignore_statistics` is not set in HTTP API `GET + // /clients/add` request then default value (false) will be used. + // + // If `ignore_statistics` is not set in HTTP API `GET /clients/update` + // request then the existing value will not be changed. + // + // This behaviour can be changed in the future versions. + IgnoreStatistics *bool `json:"ignore_statistics,omitempty"` + + // Name Name + Name *string `json:"name,omitempty"` + ParentalEnabled *bool `json:"parental_enabled,omitempty"` + + // SafeSearch Safe search settings. + SafeSearch *SafeSearchConfig `json:"safe_search,omitempty"` + SafebrowsingEnabled *bool `json:"safebrowsing_enabled,omitempty"` + // Deprecated: + SafesearchEnabled *bool `json:"safesearch_enabled,omitempty"` + Tags *[]string `json:"tags,omitempty"` + Upstreams *[]string `json:"upstreams,omitempty"` + UseGlobalBlockedServices *bool `json:"use_global_blocked_services,omitempty"` + UseGlobalSettings *bool `json:"use_global_settings,omitempty"` +} + +// ClientAuto Auto-Client information +type ClientAuto struct { + // Ip IP address + Ip *string `json:"ip,omitempty"` + + // Name Name + Name *string `json:"name,omitempty"` + + // Source The source of this information + Source *string `json:"source,omitempty"` + WhoisInfo *WhoisInfo `json:"whois_info,omitempty"` +} + +// ClientDelete Client delete request +type ClientDelete struct { + Name *string `json:"name,omitempty"` +} + +// ClientFindSubEntry Client information. +type ClientFindSubEntry struct { + BlockedServices *[]string `json:"blocked_services,omitempty"` + + // Disallowed Whether the client's IP is blocked or not. + Disallowed *bool `json:"disallowed,omitempty"` + + // DisallowedRule The rule due to which the client is disallowed. If disallowed is set to true, and this string is empty, then the client IP is disallowed by the "allowed IP list", that is it is not included in the allowed list. + DisallowedRule *string `json:"disallowed_rule,omitempty"` + FilteringEnabled *bool `json:"filtering_enabled,omitempty"` + + // Ids IP, CIDR, MAC, or ClientID. + Ids *[]string `json:"ids,omitempty"` + IgnoreQuerylog *bool `json:"ignore_querylog,omitempty"` + IgnoreStatistics *bool `json:"ignore_statistics,omitempty"` + + // Name Name + Name *string `json:"name,omitempty"` + ParentalEnabled *bool `json:"parental_enabled,omitempty"` + + // SafeSearch Safe search settings. + SafeSearch *SafeSearchConfig `json:"safe_search,omitempty"` + SafebrowsingEnabled *bool `json:"safebrowsing_enabled,omitempty"` + // Deprecated: + SafesearchEnabled *bool `json:"safesearch_enabled,omitempty"` + Upstreams *[]string `json:"upstreams,omitempty"` + UseGlobalBlockedServices *bool `json:"use_global_blocked_services,omitempty"` + UseGlobalSettings *bool `json:"use_global_settings,omitempty"` + WhoisInfo *WhoisInfo `json:"whois_info,omitempty"` +} + +// ClientUpdate Client update request +type ClientUpdate struct { + // Data Client information. + Data *Client `json:"data,omitempty"` + Name *string `json:"name,omitempty"` +} + +// Clients defines model for Clients. +type Clients struct { + // AutoClients Auto-Clients array + AutoClients *ClientsAutoArray `json:"auto_clients,omitempty"` + + // Clients Clients array + Clients *ClientsArray `json:"clients,omitempty"` + SupportedTags *[]string `json:"supported_tags,omitempty"` +} + +// ClientsArray Clients array +type ClientsArray = []Client + +// ClientsAutoArray Auto-Clients array +type ClientsAutoArray = []ClientAuto + +// ClientsFindEntry defines model for ClientsFindEntry. +type ClientsFindEntry map[string]ClientFindSubEntry + +// ClientsFindResponse Client search results. +type ClientsFindResponse = []ClientsFindEntry + +// DNSConfig DNS server configuration +type DNSConfig struct { + // BlockedResponseTtl TTL for blocked responses. + BlockedResponseTtl *int `json:"blocked_response_ttl,omitempty"` + BlockingIpv4 *string `json:"blocking_ipv4,omitempty"` + BlockingIpv6 *string `json:"blocking_ipv6,omitempty"` + BlockingMode *DNSConfigBlockingMode `json:"blocking_mode,omitempty"` + + // BootstrapDns Bootstrap servers, port is optional after colon. Empty value will reset it to default values. + BootstrapDns *[]string `json:"bootstrap_dns,omitempty"` + CacheOptimistic *bool `json:"cache_optimistic,omitempty"` + CacheSize *int `json:"cache_size,omitempty"` + CacheTtlMax *int `json:"cache_ttl_max,omitempty"` + CacheTtlMin *int `json:"cache_ttl_min,omitempty"` + DisableIpv6 *bool `json:"disable_ipv6,omitempty"` + DnssecEnabled *bool `json:"dnssec_enabled,omitempty"` + EdnsCsCustomIp *string `json:"edns_cs_custom_ip,omitempty"` + EdnsCsEnabled *bool `json:"edns_cs_enabled,omitempty"` + EdnsCsUseCustom *bool `json:"edns_cs_use_custom,omitempty"` + + // FallbackDns List of fallback DNS servers used when upstream DNS servers are not responding. Empty value will clear the list. + FallbackDns *[]string `json:"fallback_dns,omitempty"` + + // LocalPtrUpstreams Upstream servers, port is optional after colon. Empty value will reset it to default values. + LocalPtrUpstreams *[]string `json:"local_ptr_upstreams,omitempty"` + + // ProtectionDisabledUntil Protection is pause until this time. Nullable. + ProtectionDisabledUntil *string `json:"protection_disabled_until,omitempty"` + ProtectionEnabled *bool `json:"protection_enabled,omitempty"` + Ratelimit *int `json:"ratelimit,omitempty"` + ResolveClients *bool `json:"resolve_clients,omitempty"` + + // UpstreamDns Upstream servers, port is optional after colon. Empty value will reset it to default values. + UpstreamDns *[]string `json:"upstream_dns,omitempty"` + UpstreamDnsFile *string `json:"upstream_dns_file,omitempty"` + UpstreamMode *interface{} `json:"upstream_mode,omitempty"` + UsePrivatePtrResolvers *bool `json:"use_private_ptr_resolvers,omitempty"` +} + +// DNSConfigBlockingMode defines model for DNSConfig.BlockingMode. +type DNSConfigBlockingMode string + +// DayRange The single interval within a day. It begins at the `start` and ends before the `end`. +type DayRange struct { + // End The number of milliseconds elapsed from the start of a day. It is expected to be rounded to minutes. The maximum value is `86400000` (24 hours). + End *float32 `json:"end,omitempty"` + + // Start The number of milliseconds elapsed from the start of a day. It must be less than `end` and is expected to be rounded to minutes. So the maximum value is `86340000` (23 hours and 59 minutes). + Start *float32 `json:"start,omitempty"` +} + +// DhcpConfig defines model for DhcpConfig. +type DhcpConfig struct { + Enabled *bool `json:"enabled,omitempty"` + InterfaceName *string `json:"interface_name,omitempty"` + V4 *DhcpConfigV4 `json:"v4,omitempty"` + V6 *DhcpConfigV6 `json:"v6,omitempty"` +} + +// DhcpConfigV4 defines model for DhcpConfigV4. +type DhcpConfigV4 struct { + GatewayIp *string `json:"gateway_ip,omitempty"` + LeaseDuration *int `json:"lease_duration,omitempty"` + RangeEnd *string `json:"range_end,omitempty"` + RangeStart *string `json:"range_start,omitempty"` + SubnetMask *string `json:"subnet_mask,omitempty"` +} + +// DhcpConfigV6 defines model for DhcpConfigV6. +type DhcpConfigV6 struct { + LeaseDuration *int `json:"lease_duration,omitempty"` + RangeStart *string `json:"range_start,omitempty"` +} + +// DhcpFindActiveReq Request for checking for other DHCP servers in the network. +type DhcpFindActiveReq struct { + // Interface The name of the network interface + Interface *string `json:"interface,omitempty"` +} + +// DhcpLease DHCP lease information +type DhcpLease struct { + Expires string `json:"expires"` + Hostname string `json:"hostname"` + Ip string `json:"ip"` + Mac string `json:"mac"` +} + +// DhcpSearchResult Information about a DHCP server discovered in the current network. +type DhcpSearchResult struct { + V4 *DhcpSearchV4 `json:"v4,omitempty"` + V6 *DhcpSearchV6 `json:"v6,omitempty"` +} + +// DhcpSearchResultOtherServer defines model for DhcpSearchResultOtherServer. +type DhcpSearchResultOtherServer struct { + // Error Set if found=error + Error *string `json:"error,omitempty"` + + // Found The result of searching the other DHCP server. + Found *DhcpSearchResultOtherServerFound `json:"found,omitempty"` +} + +// DhcpSearchResultOtherServerFound The result of searching the other DHCP server. +type DhcpSearchResultOtherServerFound string + +// DhcpSearchResultStaticIP defines model for DhcpSearchResultStaticIP. +type DhcpSearchResultStaticIP struct { + // Ip Set if static=no + Ip *string `json:"ip,omitempty"` + + // Static The result of determining static IP address. + Static *DhcpSearchResultStaticIPStatic `json:"static,omitempty"` +} + +// DhcpSearchResultStaticIPStatic The result of determining static IP address. +type DhcpSearchResultStaticIPStatic string + +// DhcpSearchV4 defines model for DhcpSearchV4. +type DhcpSearchV4 struct { + OtherServer *DhcpSearchResultOtherServer `json:"other_server,omitempty"` + StaticIp *DhcpSearchResultStaticIP `json:"static_ip,omitempty"` +} + +// DhcpSearchV6 defines model for DhcpSearchV6. +type DhcpSearchV6 struct { + OtherServer *DhcpSearchResultOtherServer `json:"other_server,omitempty"` +} + +// DhcpStaticLease DHCP static lease information +type DhcpStaticLease struct { + Hostname string `json:"hostname"` + Ip string `json:"ip"` + Mac string `json:"mac"` +} + +// DhcpStatus Built-in DHCP server configuration and status +type DhcpStatus struct { + Enabled *bool `json:"enabled,omitempty"` + InterfaceName *string `json:"interface_name,omitempty"` + Leases []DhcpLease `json:"leases"` + StaticLeases *[]DhcpStaticLease `json:"static_leases,omitempty"` + V4 *DhcpConfigV4 `json:"v4,omitempty"` + V6 *DhcpConfigV6 `json:"v6,omitempty"` +} + +// DnsAnswer DNS answer section +type DnsAnswer struct { + Ttl *uint32 `json:"ttl,omitempty"` + Type *string `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} + +// DnsQuestion DNS question section +type DnsQuestion struct { + Class *string `json:"class,omitempty"` + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + UnicodeName *string `json:"unicode_name,omitempty"` +} + +// Error A generic JSON error response. +type Error struct { + // Message The error message, an opaque string. + Message *string `json:"message,omitempty"` +} + +// Filter Filter subscription info +type Filter struct { + Enabled bool `json:"enabled"` + Id int64 `json:"id"` + LastUpdated *time.Time `json:"last_updated,omitempty"` + Name string `json:"name"` + RulesCount uint32 `json:"rules_count"` + Url string `json:"url"` +} + +// FilterCheckHostResponse Check Host Result +type FilterCheckHostResponse struct { + // Cname Set if reason=Rewrite + Cname *string `json:"cname,omitempty"` + + // FilterId In case if there's a rule applied to this DNS request, this is ID of the filter list that the rule belongs to. + // Deprecated: use `rules[*].filter_list_id` instead. + // Deprecated: + FilterId *int `json:"filter_id,omitempty"` + + // IpAddrs Set if reason=Rewrite + IpAddrs *[]string `json:"ip_addrs,omitempty"` + + // Reason Request filtering status. + Reason *FilterCheckHostResponseReason `json:"reason,omitempty"` + + // Rule Filtering rule applied to the request (if any). + // Deprecated: use `rules[*].text` instead. + // Deprecated: + Rule *string `json:"rule,omitempty"` + + // Rules Applied rules. + Rules *[]ResultRule `json:"rules,omitempty"` + + // ServiceName Set if reason=FilteredBlockedService + ServiceName *string `json:"service_name,omitempty"` +} + +// FilterCheckHostResponseReason Request filtering status. +type FilterCheckHostResponseReason string + +// FilterConfig Filtering settings +type FilterConfig struct { + Enabled *bool `json:"enabled,omitempty"` + Interval *int `json:"interval,omitempty"` +} + +// FilterRefreshRequest Refresh Filters request data +type FilterRefreshRequest struct { + Whitelist *bool `json:"whitelist,omitempty"` +} + +// FilterRefreshResponse /filtering/refresh response data +type FilterRefreshResponse struct { + Updated *int `json:"updated,omitempty"` +} + +// FilterSetUrl Filtering URL settings +type FilterSetUrl struct { + // Data Filter update data + Data *FilterSetUrlData `json:"data,omitempty"` + Url *string `json:"url,omitempty"` + Whitelist *bool `json:"whitelist,omitempty"` +} + +// FilterSetUrlData Filter update data +type FilterSetUrlData struct { + Enabled bool `json:"enabled"` + Name string `json:"name"` + Url string `json:"url"` +} + +// FilterStatus Filtering settings +type FilterStatus struct { + Enabled *bool `json:"enabled,omitempty"` + Filters *[]Filter `json:"filters,omitempty"` + Interval *int `json:"interval,omitempty"` + UserRules *[]string `json:"user_rules,omitempty"` + WhitelistFilters *[]Filter `json:"whitelist_filters,omitempty"` +} + +// GetQueryLogConfigResponse Query log configuration +type GetQueryLogConfigResponse struct { + // AnonymizeClientIp Anonymize clients' IP addresses + AnonymizeClientIp bool `json:"anonymize_client_ip"` + + // Enabled Is query log enabled + Enabled bool `json:"enabled"` + + // Ignored List of host names, which should not be written to log + Ignored []string `json:"ignored"` + + // Interval Time period for query log rotation in milliseconds. + Interval float32 `json:"interval"` +} + +// GetStatsConfigResponse Statistics configuration +type GetStatsConfigResponse struct { + // Enabled Are statistics enabled + Enabled bool `json:"enabled"` + + // Ignored List of host names, which should not be counted + Ignored []string `json:"ignored"` + + // Interval Statistics rotation interval in milliseconds + Interval float32 `json:"interval"` +} + +// GetVersionRequest /version.json request data +type GetVersionRequest struct { + // RecheckNow If false, server will check for a new version data only once in several hours. + RecheckNow *bool `json:"recheck_now,omitempty"` +} + +// InitialConfiguration AdGuard Home initial configuration for the first-install wizard. +type InitialConfiguration struct { + // Dns Port information + Dns AddressInfo `json:"dns"` + + // Password Basic auth password + Password string `json:"password"` + + // Username Basic auth username + Username string `json:"username"` + + // Web Port information + Web AddressInfo `json:"web"` +} + +// LanguageSettings Language settings object. +type LanguageSettings struct { + // Language The current language or the language to set. + Language string `json:"language"` +} + +// Login Login request data +type Login struct { + // Name User name + Name *string `json:"name,omitempty"` + + // Password Password + Password *string `json:"password,omitempty"` +} + +// NetInterface Network interface info +type NetInterface struct { + // Flags Flags could be any combination of the following values, divided by the "|" character: "up", "broadcast", "loopback", "pointtopoint" and "multicast". + Flags string `json:"flags"` + HardwareAddress string `json:"hardware_address"` + IpAddresses *[]string `json:"ip_addresses,omitempty"` + Mtu int `json:"mtu"` + Name string `json:"name"` +} + +// NetInterfaces Network interfaces dictionary, keys are interface names. +type NetInterfaces map[string]NetInterface + +// ProfileInfo Information about the current user +type ProfileInfo struct { + Language string `json:"language"` + Name string `json:"name"` + + // Theme Interface theme + Theme ProfileInfoTheme `json:"theme"` +} + +// ProfileInfoTheme Interface theme +type ProfileInfoTheme string + +// PutQueryLogConfigUpdateRequest Query log configuration +type PutQueryLogConfigUpdateRequest = GetQueryLogConfigResponse + +// PutStatsConfigUpdateRequest Statistics configuration +type PutStatsConfigUpdateRequest = GetStatsConfigResponse + +// QueryLog Query log +type QueryLog struct { + Data *[]QueryLogItem `json:"data,omitempty"` + Oldest *string `json:"oldest,omitempty"` +} + +// QueryLogConfig Query log configuration +type QueryLogConfig struct { + // AnonymizeClientIp Anonymize clients' IP addresses + AnonymizeClientIp *bool `json:"anonymize_client_ip,omitempty"` + + // Enabled Is query log enabled + Enabled *bool `json:"enabled,omitempty"` + + // Interval Time period for query log rotation. + Interval *QueryLogConfigInterval `json:"interval,omitempty"` +} + +// QueryLogConfigInterval Time period for query log rotation. +type QueryLogConfigInterval float32 + +// QueryLogItem Query log item +type QueryLogItem struct { + Answer *[]DnsAnswer `json:"answer,omitempty"` + + // AnswerDnssec If true, the response had the Authenticated Data (AD) flag set. + AnswerDnssec *bool `json:"answer_dnssec,omitempty"` + + // Cached Defines if the response has been served from cache. + Cached *bool `json:"cached,omitempty"` + + // Client The client's IP address. + Client *string `json:"client,omitempty"` + + // ClientId The ClientID, if provided in DoH, DoQ, or DoT. + ClientId *string `json:"client_id,omitempty"` + + // ClientInfo Client information for a query log item. + ClientInfo *QueryLogItemClient `json:"client_info,omitempty"` + ClientProto *interface{} `json:"client_proto,omitempty"` + + // Ecs The IP network defined by an EDNS Client-Subnet option in the request message if any. + Ecs *string `json:"ecs,omitempty"` + ElapsedMs *string `json:"elapsedMs,omitempty"` + + // FilterId In case if there's a rule applied to this DNS request, this is ID of the filter list that the rule belongs to. + // Deprecated: use `rules[*].filter_list_id` instead. + // Deprecated: + FilterId *int `json:"filterId,omitempty"` + + // OriginalAnswer Answer from upstream server (optional) + OriginalAnswer *[]DnsAnswer `json:"original_answer,omitempty"` + + // Question DNS question section + Question *DnsQuestion `json:"question,omitempty"` + + // Reason Request filtering status. + Reason *QueryLogItemReason `json:"reason,omitempty"` + + // Rule Filtering rule applied to the request (if any). + // Deprecated: use `rules[*].text` instead. + // Deprecated: + Rule *string `json:"rule,omitempty"` + + // Rules Applied rules. + Rules *[]ResultRule `json:"rules,omitempty"` + + // ServiceName Set if reason=FilteredBlockedService + ServiceName *string `json:"service_name,omitempty"` + + // Status DNS response status + Status *string `json:"status,omitempty"` + + // Time DNS request processing start time + Time *string `json:"time,omitempty"` + + // Upstream Upstream URL starting with tcp://, tls://, https://, or with an IP address. + Upstream *string `json:"upstream,omitempty"` +} + +// QueryLogItemReason Request filtering status. +type QueryLogItemReason string + +// QueryLogItemClient Client information for a query log item. +type QueryLogItemClient struct { + // Disallowed Whether the client's IP is blocked or not. + Disallowed bool `json:"disallowed"` + + // DisallowedRule The rule due to which the client is allowed or blocked. + DisallowedRule string `json:"disallowed_rule"` + + // Name Persistent client's name or runtime client's hostname. May be empty. + Name string `json:"name"` + + // Whois Client WHOIS information, if any. + Whois QueryLogItemClientWhois `json:"whois"` +} + +// QueryLogItemClientWhois Client WHOIS information, if any. +type QueryLogItemClientWhois struct { + // City City, if any. + City *string `json:"city,omitempty"` + + // Country Country, if any. + Country *string `json:"country,omitempty"` + + // Orgname Organization name, if any. + Orgname *string `json:"orgname,omitempty"` +} + +// RemoveUrlRequest /remove_url request data +type RemoveUrlRequest struct { + // Url Previously added URL containing filtering rules + Url *string `json:"url,omitempty"` + Whitelist *bool `json:"whitelist,omitempty"` +} + +// ResultRule Applied rule. +type ResultRule struct { + // FilterListId In case if there's a rule applied to this DNS request, this is ID of the filter list that the rule belongs to. + FilterListId *int64 `json:"filter_list_id,omitempty"` + + // Text The text of the filtering rule applied to the request (if any). + Text *string `json:"text,omitempty"` +} + +// RewriteEntry Rewrite rule +type RewriteEntry struct { + // Answer value of A, AAAA or CNAME DNS record + Answer *string `json:"answer,omitempty"` + + // Domain Domain name + Domain *string `json:"domain,omitempty"` +} + +// RewriteList Rewrite rules array +type RewriteList = []RewriteEntry + +// RewriteUpdate Rewrite rule update object +type RewriteUpdate struct { + // Target Rewrite rule + Target *RewriteEntry `json:"target,omitempty"` + + // Update Rewrite rule + Update *RewriteEntry `json:"update,omitempty"` +} + +// SafeSearchConfig Safe search settings. +type SafeSearchConfig struct { + Bing *bool `json:"bing,omitempty"` + Duckduckgo *bool `json:"duckduckgo,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Google *bool `json:"google,omitempty"` + Pixabay *bool `json:"pixabay,omitempty"` + Yandex *bool `json:"yandex,omitempty"` + Youtube *bool `json:"youtube,omitempty"` +} + +// Schedule Sets periods of inactivity for filtering blocked services. The schedule contains 7 days (Sunday to Saturday) and a time zone. +type Schedule struct { + // Fri The single interval within a day. It begins at the `start` and ends before the `end`. + Fri *DayRange `json:"fri,omitempty"` + + // Mon The single interval within a day. It begins at the `start` and ends before the `end`. + Mon *DayRange `json:"mon,omitempty"` + + // Sat The single interval within a day. It begins at the `start` and ends before the `end`. + Sat *DayRange `json:"sat,omitempty"` + + // Sun The single interval within a day. It begins at the `start` and ends before the `end`. + Sun *DayRange `json:"sun,omitempty"` + + // Thu The single interval within a day. It begins at the `start` and ends before the `end`. + Thu *DayRange `json:"thu,omitempty"` + + // TimeZone Time zone name according to IANA time zone database. For example `Europe/Brussels`. `Local` represents the system's local time zone. + TimeZone *string `json:"time_zone,omitempty"` + + // Tue The single interval within a day. It begins at the `start` and ends before the `end`. + Tue *DayRange `json:"tue,omitempty"` + + // Wed The single interval within a day. It begins at the `start` and ends before the `end`. + Wed *DayRange `json:"wed,omitempty"` +} + +// ServerStatus AdGuard Home server status and configuration +type ServerStatus struct { + DhcpAvailable *bool `json:"dhcp_available,omitempty"` + DnsAddresses []string `json:"dns_addresses"` + DnsPort uint16 `json:"dns_port"` + HttpPort uint16 `json:"http_port"` + Language string `json:"language"` + ProtectionDisabledDuration *int64 `json:"protection_disabled_duration,omitempty"` + ProtectionEnabled bool `json:"protection_enabled"` + Running bool `json:"running"` + Version string `json:"version"` +} + +// SetProtectionRequest Protection state configuration +type SetProtectionRequest struct { + // Duration Duration of a pause, in milliseconds. Enabled should be false. + Duration *uint64 `json:"duration,omitempty"` + Enabled bool `json:"enabled"` +} + +// SetRulesRequest Custom filtering rules setting request. +type SetRulesRequest struct { + Rules *[]string `json:"rules,omitempty"` +} + +// Stats Server statistics data +type Stats struct { + // AvgProcessingTime Average time in seconds on processing a DNS request + AvgProcessingTime *float32 `json:"avg_processing_time,omitempty"` + BlockedFiltering *[]int `json:"blocked_filtering,omitempty"` + DnsQueries *[]int `json:"dns_queries,omitempty"` + + // NumBlockedFiltering Number of requests blocked by filtering rules + NumBlockedFiltering *int `json:"num_blocked_filtering,omitempty"` + + // NumDnsQueries Total number of DNS queries + NumDnsQueries *int `json:"num_dns_queries,omitempty"` + + // NumReplacedParental Number of blocked adult websites + NumReplacedParental *int `json:"num_replaced_parental,omitempty"` + + // NumReplacedSafebrowsing Number of requests blocked by safebrowsing module + NumReplacedSafebrowsing *int `json:"num_replaced_safebrowsing,omitempty"` + + // NumReplacedSafesearch Number of requests blocked by safesearch module + NumReplacedSafesearch *int `json:"num_replaced_safesearch,omitempty"` + ReplacedParental *[]int `json:"replaced_parental,omitempty"` + ReplacedSafebrowsing *[]int `json:"replaced_safebrowsing,omitempty"` + + // TimeUnits Time units + TimeUnits *StatsTimeUnits `json:"time_units,omitempty"` + TopBlockedDomains *[]TopArrayEntry `json:"top_blocked_domains,omitempty"` + TopClients *[]TopArrayEntry `json:"top_clients,omitempty"` + TopQueriedDomains *[]TopArrayEntry `json:"top_queried_domains,omitempty"` + + // TopUpstreamsAvgTime Average processing time in seconds of requests from each upstream. + TopUpstreamsAvgTime *[]TopArrayEntry `json:"top_upstreams_avg_time,omitempty"` + + // TopUpstreamsResponses Total number of responses from each upstream. + TopUpstreamsResponses *[]TopArrayEntry `json:"top_upstreams_responses,omitempty"` +} + +// StatsTimeUnits Time units +type StatsTimeUnits string + +// StatsConfig Statistics configuration +type StatsConfig struct { + // Interval Time period to keep the data. `0` means that the statistics is disabled. + Interval *StatsConfigInterval `json:"interval,omitempty"` +} + +// StatsConfigInterval Time period to keep the data. `0` means that the statistics is disabled. +type StatsConfigInterval int + +// TlsConfig TLS configuration settings and status +type TlsConfig struct { + // CertificateChain Base64 string with PEM-encoded certificates chain + CertificateChain *string `json:"certificate_chain,omitempty"` + + // CertificatePath Path to certificate file + CertificatePath *string `json:"certificate_path,omitempty"` + + // DnsNames The value of SubjectAltNames field of the first certificate in the chain. + DnsNames *[]string `json:"dns_names,omitempty"` + + // Enabled enabled is the encryption (DoT/DoH/HTTPS) status + Enabled *bool `json:"enabled,omitempty"` + + // ForceHttps if true, forces HTTP->HTTPS redirect + ForceHttps *bool `json:"force_https,omitempty"` + + // Issuer The issuer of the first certificate in the chain. + Issuer *string `json:"issuer,omitempty"` + + // KeyType Key type. + KeyType *TlsConfigKeyType `json:"key_type,omitempty"` + + // NotAfter The NotAfter field of the first certificate in the chain. + NotAfter *string `json:"not_after,omitempty"` + + // NotBefore The NotBefore field of the first certificate in the chain. + NotBefore *string `json:"not_before,omitempty"` + + // PortDnsOverQuic DNS-over-QUIC port. If 0, DoQ will be disabled. + PortDnsOverQuic *uint16 `json:"port_dns_over_quic,omitempty"` + + // PortDnsOverTls DNS-over-TLS port. If 0, DoT will be disabled. + PortDnsOverTls *uint16 `json:"port_dns_over_tls,omitempty"` + + // PortHttps HTTPS port. If 0, HTTPS will be disabled. + PortHttps *uint16 `json:"port_https,omitempty"` + + // PrivateKey Base64 string with PEM-encoded private key + PrivateKey *string `json:"private_key,omitempty"` + + // PrivateKeyPath Path to private key file + PrivateKeyPath *string `json:"private_key_path,omitempty"` + + // PrivateKeySaved Set to true if the user has previously saved a private key as a string. This is used so that the server and the client don't have to send the private key between each other every time, which might lead to security issues. + PrivateKeySaved *bool `json:"private_key_saved,omitempty"` + + // ServerName server_name is the hostname of your HTTPS/TLS server + ServerName *string `json:"server_name,omitempty"` + + // Subject The subject of the first certificate in the chain. + Subject *string `json:"subject,omitempty"` + + // ValidCert Set to true if the specified certificates chain is a valid chain of X509 certificates. + ValidCert *bool `json:"valid_cert,omitempty"` + + // ValidChain Set to true if the specified certificates chain is verified and issued by a known CA. + ValidChain *bool `json:"valid_chain,omitempty"` + + // ValidKey Set to true if the key is a valid private key. + ValidKey *bool `json:"valid_key,omitempty"` + + // ValidPair Set to true if both certificate and private key are correct. + ValidPair *bool `json:"valid_pair,omitempty"` + + // WarningValidation A validation warning message with the issue description. + WarningValidation *string `json:"warning_validation,omitempty"` +} + +// TlsConfigKeyType Key type. +type TlsConfigKeyType string + +// TopArrayEntry Represent the number of hits or time duration per key (url, domain, or client IP). +type TopArrayEntry struct { + DomainOrIp *float32 `json:"domain_or_ip,omitempty"` + AdditionalProperties map[string]float32 `json:"-"` +} + +// UpstreamsConfig Upstream configuration to be tested +type UpstreamsConfig struct { + // BootstrapDns Bootstrap DNS servers, port is optional after colon. + BootstrapDns []string `json:"bootstrap_dns"` + + // FallbackDns Fallback DNS servers, port is optional after colon. + FallbackDns *[]string `json:"fallback_dns,omitempty"` + + // PrivateUpstream Local PTR resolvers, port is optional after colon. + PrivateUpstream *[]string `json:"private_upstream,omitempty"` + + // UpstreamDns Upstream DNS servers, port is optional after colon. + UpstreamDns []string `json:"upstream_dns"` +} + +// UpstreamsConfigResponse Upstreams configuration response +type UpstreamsConfigResponse map[string]string + +// VersionInfo Information about the latest available version of AdGuard Home. +type VersionInfo struct { + Announcement *string `json:"announcement,omitempty"` + AnnouncementUrl *string `json:"announcement_url,omitempty"` + CanAutoupdate *bool `json:"can_autoupdate,omitempty"` + + // Disabled If true then other fields doesn't appear. + Disabled bool `json:"disabled"` + NewVersion *string `json:"new_version,omitempty"` +} + +// WhoisInfo defines model for WhoisInfo. +type WhoisInfo map[string]string + +// DhcpStaticLeaseBody DHCP static lease information +type DhcpStaticLeaseBody = DhcpStaticLease + +// RewriteEntryBody Rewrite rule +type RewriteEntryBody = RewriteEntry + +// RewriteUpdateBody Rewrite rule update object +type RewriteUpdateBody = RewriteUpdate + +// TlsConfigBody TLS configuration settings and status +type TlsConfigBody = TlsConfig + +// MobileConfigDoHParams defines parameters for MobileConfigDoH. +type MobileConfigDoHParams struct { + // Host Host for which the config is generated. If no host is provided, `tls.server_name` from the configuration file is used. If `tls.server_name` is not set, the API returns an error with a 500 status. + Host string `form:"host" json:"host"` + + // ClientId ClientID. + ClientId *string `form:"client_id,omitempty" json:"client_id,omitempty"` +} + +// MobileConfigDoTParams defines parameters for MobileConfigDoT. +type MobileConfigDoTParams struct { + // Host Host for which the config is generated. If no host is provided, `tls.server_name` from the configuration file is used. If `tls.server_name` is not set, the API returns an error with a 500 status. + Host string `form:"host" json:"host"` + + // ClientId ClientID. + ClientId *string `form:"client_id,omitempty" json:"client_id,omitempty"` +} + +// ClientsFindParams defines parameters for ClientsFind. +type ClientsFindParams struct { + // Ip0 Filter by IP address or ClientIDs. Parameters with names `ip1`, `ip2`, and so on are also accepted and interpreted as "ip0 OR ip1 OR ip2". + // TODO(a.garipov): Replace with a better query API. + Ip0 *string `form:"ip0,omitempty" json:"ip0,omitempty"` +} + +// FilteringCheckHostParams defines parameters for FilteringCheckHost. +type FilteringCheckHostParams struct { + // Name Filter by host name + Name *string `form:"name,omitempty" json:"name,omitempty"` +} + +// QueryLogParams defines parameters for QueryLog. +type QueryLogParams struct { + // OlderThan Filter by older than + OlderThan *string `form:"older_than,omitempty" json:"older_than,omitempty"` + + // Offset Specify the ranking number of the first item on the page. Even though it is possible to use "offset" and "older_than", we recommend choosing one of them and sticking to it. + Offset *int `form:"offset,omitempty" json:"offset,omitempty"` + + // Limit Limit the number of records to be returned + Limit *int `form:"limit,omitempty" json:"limit,omitempty"` + + // Search Filter by domain name or client IP + Search *string `form:"search,omitempty" json:"search,omitempty"` + + // ResponseStatus Filter by response status + ResponseStatus *QueryLogParamsResponseStatus `form:"response_status,omitempty" json:"response_status,omitempty"` +} + +// QueryLogParamsResponseStatus defines parameters for QueryLog. +type QueryLogParamsResponseStatus string + +// AccessSetJSONRequestBody defines body for AccessSet for application/json ContentType. +type AccessSetJSONRequestBody = AccessSetRequest + +// BlockedServicesSetJSONRequestBody defines body for BlockedServicesSet for application/json ContentType. +type BlockedServicesSetJSONRequestBody = BlockedServicesArray + +// BlockedServicesScheduleUpdateJSONRequestBody defines body for BlockedServicesScheduleUpdate for application/json ContentType. +type BlockedServicesScheduleUpdateJSONRequestBody = BlockedServicesSchedule + +// ClientsAddJSONRequestBody defines body for ClientsAdd for application/json ContentType. +type ClientsAddJSONRequestBody = Client + +// ClientsDeleteJSONRequestBody defines body for ClientsDelete for application/json ContentType. +type ClientsDeleteJSONRequestBody = ClientDelete + +// ClientsUpdateJSONRequestBody defines body for ClientsUpdate for application/json ContentType. +type ClientsUpdateJSONRequestBody = ClientUpdate + +// DhcpAddStaticLeaseJSONRequestBody defines body for DhcpAddStaticLease for application/json ContentType. +type DhcpAddStaticLeaseJSONRequestBody = DhcpStaticLease + +// CheckActiveDhcpJSONRequestBody defines body for CheckActiveDhcp for application/json ContentType. +type CheckActiveDhcpJSONRequestBody = DhcpFindActiveReq + +// DhcpRemoveStaticLeaseJSONRequestBody defines body for DhcpRemoveStaticLease for application/json ContentType. +type DhcpRemoveStaticLeaseJSONRequestBody = DhcpStaticLease + +// DhcpSetConfigJSONRequestBody defines body for DhcpSetConfig for application/json ContentType. +type DhcpSetConfigJSONRequestBody = DhcpConfig + +// DhcpUpdateStaticLeaseJSONRequestBody defines body for DhcpUpdateStaticLease for application/json ContentType. +type DhcpUpdateStaticLeaseJSONRequestBody = DhcpStaticLease + +// DnsConfigJSONRequestBody defines body for DnsConfig for application/json ContentType. +type DnsConfigJSONRequestBody = DNSConfig + +// FilteringAddURLJSONRequestBody defines body for FilteringAddURL for application/json ContentType. +type FilteringAddURLJSONRequestBody = AddUrlRequest + +// FilteringConfigJSONRequestBody defines body for FilteringConfig for application/json ContentType. +type FilteringConfigJSONRequestBody = FilterConfig + +// FilteringRefreshJSONRequestBody defines body for FilteringRefresh for application/json ContentType. +type FilteringRefreshJSONRequestBody = FilterRefreshRequest + +// FilteringRemoveURLJSONRequestBody defines body for FilteringRemoveURL for application/json ContentType. +type FilteringRemoveURLJSONRequestBody = RemoveUrlRequest + +// FilteringSetRulesJSONRequestBody defines body for FilteringSetRules for application/json ContentType. +type FilteringSetRulesJSONRequestBody = SetRulesRequest + +// FilteringSetURLJSONRequestBody defines body for FilteringSetURL for application/json ContentType. +type FilteringSetURLJSONRequestBody = FilterSetUrl + +// ChangeLanguageJSONRequestBody defines body for ChangeLanguage for application/json ContentType. +type ChangeLanguageJSONRequestBody = LanguageSettings + +// InstallCheckConfigJSONRequestBody defines body for InstallCheckConfig for application/json ContentType. +type InstallCheckConfigJSONRequestBody = CheckConfigRequest + +// InstallConfigureJSONRequestBody defines body for InstallConfigure for application/json ContentType. +type InstallConfigureJSONRequestBody = InitialConfiguration + +// LoginJSONRequestBody defines body for Login for application/json ContentType. +type LoginJSONRequestBody = Login + +// UpdateProfileJSONRequestBody defines body for UpdateProfile for application/json ContentType. +type UpdateProfileJSONRequestBody = ProfileInfo + +// SetProtectionJSONRequestBody defines body for SetProtection for application/json ContentType. +type SetProtectionJSONRequestBody = SetProtectionRequest + +// PutQueryLogConfigJSONRequestBody defines body for PutQueryLogConfig for application/json ContentType. +type PutQueryLogConfigJSONRequestBody = PutQueryLogConfigUpdateRequest + +// QueryLogConfigJSONRequestBody defines body for QueryLogConfig for application/json ContentType. +type QueryLogConfigJSONRequestBody = QueryLogConfig + +// RewriteAddJSONRequestBody defines body for RewriteAdd for application/json ContentType. +type RewriteAddJSONRequestBody = RewriteEntry + +// RewriteDeleteJSONRequestBody defines body for RewriteDelete for application/json ContentType. +type RewriteDeleteJSONRequestBody = RewriteEntry + +// RewriteUpdateJSONRequestBody defines body for RewriteUpdate for application/json ContentType. +type RewriteUpdateJSONRequestBody = RewriteUpdate + +// SafesearchSettingsJSONRequestBody defines body for SafesearchSettings for application/json ContentType. +type SafesearchSettingsJSONRequestBody = SafeSearchConfig + +// PutStatsConfigJSONRequestBody defines body for PutStatsConfig for application/json ContentType. +type PutStatsConfigJSONRequestBody = PutStatsConfigUpdateRequest + +// StatsConfigJSONRequestBody defines body for StatsConfig for application/json ContentType. +type StatsConfigJSONRequestBody = StatsConfig + +// TestUpstreamDNSJSONRequestBody defines body for TestUpstreamDNS for application/json ContentType. +type TestUpstreamDNSJSONRequestBody = UpstreamsConfig + +// TlsConfigureJSONRequestBody defines body for TlsConfigure for application/json ContentType. +type TlsConfigureJSONRequestBody = TlsConfig + +// TlsValidateJSONRequestBody defines body for TlsValidate for application/json ContentType. +type TlsValidateJSONRequestBody = TlsConfig + +// GetVersionJsonJSONRequestBody defines body for GetVersionJson for application/json ContentType. +type GetVersionJsonJSONRequestBody = GetVersionRequest + +// Getter for additional properties for TopArrayEntry. Returns the specified +// element and whether it was found +func (a TopArrayEntry) Get(fieldName string) (value float32, found bool) { + if a.AdditionalProperties != nil { + value, found = a.AdditionalProperties[fieldName] + } + return +} + +// Setter for additional properties for TopArrayEntry +func (a *TopArrayEntry) Set(fieldName string, value float32) { + if a.AdditionalProperties == nil { + a.AdditionalProperties = make(map[string]float32) + } + a.AdditionalProperties[fieldName] = value +} + +// Override default JSON handling for TopArrayEntry to handle AdditionalProperties +func (a *TopArrayEntry) UnmarshalJSON(b []byte) error { + object := make(map[string]json.RawMessage) + err := json.Unmarshal(b, &object) + if err != nil { + return err + } + + if raw, found := object["domain_or_ip"]; found { + err = json.Unmarshal(raw, &a.DomainOrIp) + if err != nil { + return fmt.Errorf("error reading 'domain_or_ip': %w", err) + } + delete(object, "domain_or_ip") + } + + if len(object) != 0 { + a.AdditionalProperties = make(map[string]float32) + for fieldName, fieldBuf := range object { + var fieldVal float32 + err := json.Unmarshal(fieldBuf, &fieldVal) + if err != nil { + return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err) + } + a.AdditionalProperties[fieldName] = fieldVal + } + } + return nil +} + +// Override default JSON handling for TopArrayEntry to handle AdditionalProperties +func (a TopArrayEntry) MarshalJSON() ([]byte, error) { + var err error + object := make(map[string]json.RawMessage) + + if a.DomainOrIp != nil { + object["domain_or_ip"], err = json.Marshal(a.DomainOrIp) + if err != nil { + return nil, fmt.Errorf("error marshaling 'domain_or_ip': %w", err) + } + } + + for fieldName, field := range a.AdditionalProperties { + object[fieldName], err = json.Marshal(field) + if err != nil { + return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err) + } + } + return json.Marshal(object) +} + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// AdguardHomeClient which conforms to the OpenAPI3 specification for this service. +type AdguardHomeClient 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 +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*AdguardHomeClient) error + +// Creates a new AdguardHomeClient, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*AdguardHomeClient, error) { + // create a client with sane default values + client := AdguardHomeClient{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *AdguardHomeClient) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *AdguardHomeClient) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // AccessList request + AccessList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AccessSetWithBody request with any body + AccessSetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + AccessSet(ctx context.Context, body AccessSetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // MobileConfigDoH request + MobileConfigDoH(ctx context.Context, params *MobileConfigDoHParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // MobileConfigDoT request + MobileConfigDoT(ctx context.Context, params *MobileConfigDoTParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BlockedServicesAll request + BlockedServicesAll(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BlockedServicesSchedule request + BlockedServicesSchedule(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BlockedServicesList request + BlockedServicesList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BlockedServicesAvailableServices request + BlockedServicesAvailableServices(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BlockedServicesSetWithBody request with any body + BlockedServicesSetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + BlockedServicesSet(ctx context.Context, body BlockedServicesSetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BlockedServicesScheduleUpdateWithBody request with any body + BlockedServicesScheduleUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + BlockedServicesScheduleUpdate(ctx context.Context, body BlockedServicesScheduleUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CacheClear request + CacheClear(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClientsStatus request + ClientsStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClientsAddWithBody request with any body + ClientsAddWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ClientsAdd(ctx context.Context, body ClientsAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClientsDeleteWithBody request with any body + ClientsDeleteWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ClientsDelete(ctx context.Context, body ClientsDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClientsFind request + ClientsFind(ctx context.Context, params *ClientsFindParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ClientsUpdateWithBody request with any body + ClientsUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ClientsUpdate(ctx context.Context, body ClientsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpAddStaticLeaseWithBody request with any body + DhcpAddStaticLeaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + DhcpAddStaticLease(ctx context.Context, body DhcpAddStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CheckActiveDhcpWithBody request with any body + CheckActiveDhcpWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CheckActiveDhcp(ctx context.Context, body CheckActiveDhcpJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpInterfaces request + DhcpInterfaces(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpRemoveStaticLeaseWithBody request with any body + DhcpRemoveStaticLeaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + DhcpRemoveStaticLease(ctx context.Context, body DhcpRemoveStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpReset request + DhcpReset(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpResetLeases request + DhcpResetLeases(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpSetConfigWithBody request with any body + DhcpSetConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + DhcpSetConfig(ctx context.Context, body DhcpSetConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpStatus request + DhcpStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DhcpUpdateStaticLeaseWithBody request with any body + DhcpUpdateStaticLeaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + DhcpUpdateStaticLease(ctx context.Context, body DhcpUpdateStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DnsConfigWithBody request with any body + DnsConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + DnsConfig(ctx context.Context, body DnsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DnsInfo request + DnsInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringAddURLWithBody request with any body + FilteringAddURLWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + FilteringAddURL(ctx context.Context, body FilteringAddURLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringCheckHost request + FilteringCheckHost(ctx context.Context, params *FilteringCheckHostParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringConfigWithBody request with any body + FilteringConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + FilteringConfig(ctx context.Context, body FilteringConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringRefreshWithBody request with any body + FilteringRefreshWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + FilteringRefresh(ctx context.Context, body FilteringRefreshJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringRemoveURLWithBody request with any body + FilteringRemoveURLWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + FilteringRemoveURL(ctx context.Context, body FilteringRemoveURLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringSetRulesWithBody request with any body + FilteringSetRulesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + FilteringSetRules(ctx context.Context, body FilteringSetRulesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringSetURLWithBody request with any body + FilteringSetURLWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + FilteringSetURL(ctx context.Context, body FilteringSetURLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FilteringStatus request + FilteringStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ChangeLanguageWithBody request with any body + ChangeLanguageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + ChangeLanguage(ctx context.Context, body ChangeLanguageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CurrentLanguage request + CurrentLanguage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // InstallCheckConfigWithBody request with any body + InstallCheckConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + InstallCheckConfig(ctx context.Context, body InstallCheckConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // InstallConfigureWithBody request with any body + InstallConfigureWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + InstallConfigure(ctx context.Context, body InstallConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // InstallGetAddresses request + InstallGetAddresses(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LoginWithBody request with any body + LoginWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + Login(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // Logout request + Logout(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ParentalDisable request + ParentalDisable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ParentalEnable request + ParentalEnable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ParentalStatus request + ParentalStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetProfile request + GetProfile(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateProfileWithBody request with any body + UpdateProfileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateProfile(ctx context.Context, body UpdateProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SetProtectionWithBody request with any body + SetProtectionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + SetProtection(ctx context.Context, body SetProtectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QueryLog request + QueryLog(ctx context.Context, params *QueryLogParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetQueryLogConfig request + GetQueryLogConfig(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutQueryLogConfigWithBody request with any body + PutQueryLogConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutQueryLogConfig(ctx context.Context, body PutQueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QuerylogClear request + QuerylogClear(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QueryLogConfigWithBody request with any body + QueryLogConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + QueryLogConfig(ctx context.Context, body QueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // QueryLogInfo request + QueryLogInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RewriteAddWithBody request with any body + RewriteAddWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RewriteAdd(ctx context.Context, body RewriteAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RewriteDeleteWithBody request with any body + RewriteDeleteWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RewriteDelete(ctx context.Context, body RewriteDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RewriteList request + RewriteList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RewriteUpdateWithBody request with any body + RewriteUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RewriteUpdate(ctx context.Context, body RewriteUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SafebrowsingDisable request + SafebrowsingDisable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SafebrowsingEnable request + SafebrowsingEnable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SafebrowsingStatus request + SafebrowsingStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SafesearchDisable request + SafesearchDisable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SafesearchEnable request + SafesearchEnable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SafesearchSettingsWithBody request with any body + SafesearchSettingsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + SafesearchSettings(ctx context.Context, body SafesearchSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // SafesearchStatus request + SafesearchStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // Stats request + Stats(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetStatsConfig request + GetStatsConfig(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PutStatsConfigWithBody request with any body + PutStatsConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PutStatsConfig(ctx context.Context, body PutStatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StatsConfigWithBody request with any body + StatsConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + StatsConfig(ctx context.Context, body StatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StatsInfo request + StatsInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // StatsReset request + StatsReset(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // Status request + Status(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TestUpstreamDNSWithBody request with any body + TestUpstreamDNSWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + TestUpstreamDNS(ctx context.Context, body TestUpstreamDNSJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TlsConfigureWithBody request with any body + TlsConfigureWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + TlsConfigure(ctx context.Context, body TlsConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TlsStatus request + TlsStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // TlsValidateWithBody request with any body + TlsValidateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + TlsValidate(ctx context.Context, body TlsValidateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // BeginUpdate request + BeginUpdate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetVersionJsonWithBody request with any body + GetVersionJsonWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + GetVersionJson(ctx context.Context, body GetVersionJsonJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *AdguardHomeClient) AccessList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAccessListRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) AccessSetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAccessSetRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) AccessSet(ctx context.Context, body AccessSetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAccessSetRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) MobileConfigDoH(ctx context.Context, params *MobileConfigDoHParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewMobileConfigDoHRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) MobileConfigDoT(ctx context.Context, params *MobileConfigDoTParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewMobileConfigDoTRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesAll(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesAllRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesSchedule(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesScheduleRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesListRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesAvailableServices(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesAvailableServicesRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesSetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesSetRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesSet(ctx context.Context, body BlockedServicesSetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesSetRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesScheduleUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesScheduleUpdateRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BlockedServicesScheduleUpdate(ctx context.Context, body BlockedServicesScheduleUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBlockedServicesScheduleUpdateRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) CacheClear(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCacheClearRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsAddWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsAddRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsAdd(ctx context.Context, body ClientsAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsAddRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsDeleteWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsDeleteRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsDelete(ctx context.Context, body ClientsDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsDeleteRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsFind(ctx context.Context, params *ClientsFindParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsFindRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsUpdateRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ClientsUpdate(ctx context.Context, body ClientsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewClientsUpdateRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpAddStaticLeaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpAddStaticLeaseRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpAddStaticLease(ctx context.Context, body DhcpAddStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpAddStaticLeaseRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) CheckActiveDhcpWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCheckActiveDhcpRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) CheckActiveDhcp(ctx context.Context, body CheckActiveDhcpJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCheckActiveDhcpRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpInterfaces(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpInterfacesRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpRemoveStaticLeaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpRemoveStaticLeaseRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpRemoveStaticLease(ctx context.Context, body DhcpRemoveStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpRemoveStaticLeaseRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpReset(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpResetRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpResetLeases(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpResetLeasesRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpSetConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpSetConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpSetConfig(ctx context.Context, body DhcpSetConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpSetConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpUpdateStaticLeaseWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpUpdateStaticLeaseRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DhcpUpdateStaticLease(ctx context.Context, body DhcpUpdateStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDhcpUpdateStaticLeaseRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DnsConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDnsConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DnsConfig(ctx context.Context, body DnsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDnsConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) DnsInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDnsInfoRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringAddURLWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringAddURLRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringAddURL(ctx context.Context, body FilteringAddURLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringAddURLRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringCheckHost(ctx context.Context, params *FilteringCheckHostParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringCheckHostRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringConfig(ctx context.Context, body FilteringConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringRefreshWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringRefreshRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringRefresh(ctx context.Context, body FilteringRefreshJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringRefreshRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringRemoveURLWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringRemoveURLRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringRemoveURL(ctx context.Context, body FilteringRemoveURLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringRemoveURLRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringSetRulesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringSetRulesRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringSetRules(ctx context.Context, body FilteringSetRulesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringSetRulesRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringSetURLWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringSetURLRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringSetURL(ctx context.Context, body FilteringSetURLJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringSetURLRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) FilteringStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFilteringStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ChangeLanguageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewChangeLanguageRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ChangeLanguage(ctx context.Context, body ChangeLanguageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewChangeLanguageRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) CurrentLanguage(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCurrentLanguageRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) InstallCheckConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInstallCheckConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) InstallCheckConfig(ctx context.Context, body InstallCheckConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInstallCheckConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) InstallConfigureWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInstallConfigureRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) InstallConfigure(ctx context.Context, body InstallConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInstallConfigureRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) InstallGetAddresses(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewInstallGetAddressesRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) LoginWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLoginRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) Login(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLoginRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) Logout(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLogoutRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ParentalDisable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewParentalDisableRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ParentalEnable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewParentalEnableRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) ParentalStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewParentalStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) GetProfile(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetProfileRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) UpdateProfileWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateProfileRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) UpdateProfile(ctx context.Context, body UpdateProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateProfileRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SetProtectionWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetProtectionRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SetProtection(ctx context.Context, body SetProtectionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSetProtectionRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) QueryLog(ctx context.Context, params *QueryLogParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQueryLogRequest(c.Server, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) GetQueryLogConfig(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetQueryLogConfigRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) PutQueryLogConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutQueryLogConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) PutQueryLogConfig(ctx context.Context, body PutQueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutQueryLogConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) QuerylogClear(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQuerylogClearRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) QueryLogConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQueryLogConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) QueryLogConfig(ctx context.Context, body QueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQueryLogConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) QueryLogInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewQueryLogInfoRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) RewriteAddWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewriteAddRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) RewriteAdd(ctx context.Context, body RewriteAddJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewriteAddRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) RewriteDeleteWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewriteDeleteRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) RewriteDelete(ctx context.Context, body RewriteDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewriteDeleteRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) RewriteList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewriteListRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) RewriteUpdateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewriteUpdateRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) RewriteUpdate(ctx context.Context, body RewriteUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRewriteUpdateRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafebrowsingDisable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafebrowsingDisableRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafebrowsingEnable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafebrowsingEnableRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafebrowsingStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafebrowsingStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafesearchDisable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafesearchDisableRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafesearchEnable(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafesearchEnableRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafesearchSettingsWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafesearchSettingsRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafesearchSettings(ctx context.Context, body SafesearchSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafesearchSettingsRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) SafesearchStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewSafesearchStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) Stats(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStatsRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) GetStatsConfig(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetStatsConfigRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) PutStatsConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutStatsConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) PutStatsConfig(ctx context.Context, body PutStatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPutStatsConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) StatsConfigWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStatsConfigRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) StatsConfig(ctx context.Context, body StatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStatsConfigRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) StatsInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStatsInfoRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) StatsReset(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStatsResetRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) Status(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) TestUpstreamDNSWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTestUpstreamDNSRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) TestUpstreamDNS(ctx context.Context, body TestUpstreamDNSJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTestUpstreamDNSRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) TlsConfigureWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTlsConfigureRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) TlsConfigure(ctx context.Context, body TlsConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTlsConfigureRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) TlsStatus(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTlsStatusRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) TlsValidateWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTlsValidateRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) TlsValidate(ctx context.Context, body TlsValidateJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewTlsValidateRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) BeginUpdate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewBeginUpdateRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) GetVersionJsonWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetVersionJsonRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *AdguardHomeClient) GetVersionJson(ctx context.Context, body GetVersionJsonJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetVersionJsonRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewAccessListRequest generates requests for AccessList +func NewAccessListRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/access/list") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewAccessSetRequest calls the generic AccessSet builder with application/json body +func NewAccessSetRequest(server string, body AccessSetJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAccessSetRequestWithBody(server, "application/json", bodyReader) +} + +// NewAccessSetRequestWithBody generates requests for AccessSet with any type of body +func NewAccessSetRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/access/set") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewMobileConfigDoHRequest generates requests for MobileConfigDoH +func NewMobileConfigDoHRequest(server string, params *MobileConfigDoHParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/apple/doh.mobileconfig") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "host", runtime.ParamLocationQuery, params.Host); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.ClientId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "client_id", runtime.ParamLocationQuery, *params.ClientId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewMobileConfigDoTRequest generates requests for MobileConfigDoT +func NewMobileConfigDoTRequest(server string, params *MobileConfigDoTParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/apple/dot.mobileconfig") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "host", runtime.ParamLocationQuery, params.Host); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + if params.ClientId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "client_id", runtime.ParamLocationQuery, *params.ClientId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewBlockedServicesAllRequest generates requests for BlockedServicesAll +func NewBlockedServicesAllRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/blocked_services/all") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewBlockedServicesScheduleRequest generates requests for BlockedServicesSchedule +func NewBlockedServicesScheduleRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/blocked_services/get") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewBlockedServicesListRequest generates requests for BlockedServicesList +func NewBlockedServicesListRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/blocked_services/list") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewBlockedServicesAvailableServicesRequest generates requests for BlockedServicesAvailableServices +func NewBlockedServicesAvailableServicesRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/blocked_services/services") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewBlockedServicesSetRequest calls the generic BlockedServicesSet builder with application/json body +func NewBlockedServicesSetRequest(server string, body BlockedServicesSetJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewBlockedServicesSetRequestWithBody(server, "application/json", bodyReader) +} + +// NewBlockedServicesSetRequestWithBody generates requests for BlockedServicesSet with any type of body +func NewBlockedServicesSetRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/blocked_services/set") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewBlockedServicesScheduleUpdateRequest calls the generic BlockedServicesScheduleUpdate builder with application/json body +func NewBlockedServicesScheduleUpdateRequest(server string, body BlockedServicesScheduleUpdateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewBlockedServicesScheduleUpdateRequestWithBody(server, "application/json", bodyReader) +} + +// NewBlockedServicesScheduleUpdateRequestWithBody generates requests for BlockedServicesScheduleUpdate with any type of body +func NewBlockedServicesScheduleUpdateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/blocked_services/update") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewCacheClearRequest generates requests for CacheClear +func NewCacheClearRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/cache_clear") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewClientsStatusRequest generates requests for ClientsStatus +func NewClientsStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/clients") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewClientsAddRequest calls the generic ClientsAdd builder with application/json body +func NewClientsAddRequest(server string, body ClientsAddJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewClientsAddRequestWithBody(server, "application/json", bodyReader) +} + +// NewClientsAddRequestWithBody generates requests for ClientsAdd with any type of body +func NewClientsAddRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/clients/add") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewClientsDeleteRequest calls the generic ClientsDelete builder with application/json body +func NewClientsDeleteRequest(server string, body ClientsDeleteJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewClientsDeleteRequestWithBody(server, "application/json", bodyReader) +} + +// NewClientsDeleteRequestWithBody generates requests for ClientsDelete with any type of body +func NewClientsDeleteRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/clients/delete") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewClientsFindRequest generates requests for ClientsFind +func NewClientsFindRequest(server string, params *ClientsFindParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/clients/find") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Ip0 != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "ip0", runtime.ParamLocationQuery, *params.Ip0); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewClientsUpdateRequest calls the generic ClientsUpdate builder with application/json body +func NewClientsUpdateRequest(server string, body ClientsUpdateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewClientsUpdateRequestWithBody(server, "application/json", bodyReader) +} + +// NewClientsUpdateRequestWithBody generates requests for ClientsUpdate with any type of body +func NewClientsUpdateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/clients/update") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDhcpAddStaticLeaseRequest calls the generic DhcpAddStaticLease builder with application/json body +func NewDhcpAddStaticLeaseRequest(server string, body DhcpAddStaticLeaseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewDhcpAddStaticLeaseRequestWithBody(server, "application/json", bodyReader) +} + +// NewDhcpAddStaticLeaseRequestWithBody generates requests for DhcpAddStaticLease with any type of body +func NewDhcpAddStaticLeaseRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/add_static_lease") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewCheckActiveDhcpRequest calls the generic CheckActiveDhcp builder with application/json body +func NewCheckActiveDhcpRequest(server string, body CheckActiveDhcpJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCheckActiveDhcpRequestWithBody(server, "application/json", bodyReader) +} + +// NewCheckActiveDhcpRequestWithBody generates requests for CheckActiveDhcp with any type of body +func NewCheckActiveDhcpRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/find_active_dhcp") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDhcpInterfacesRequest generates requests for DhcpInterfaces +func NewDhcpInterfacesRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/interfaces") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDhcpRemoveStaticLeaseRequest calls the generic DhcpRemoveStaticLease builder with application/json body +func NewDhcpRemoveStaticLeaseRequest(server string, body DhcpRemoveStaticLeaseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewDhcpRemoveStaticLeaseRequestWithBody(server, "application/json", bodyReader) +} + +// NewDhcpRemoveStaticLeaseRequestWithBody generates requests for DhcpRemoveStaticLease with any type of body +func NewDhcpRemoveStaticLeaseRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/remove_static_lease") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDhcpResetRequest generates requests for DhcpReset +func NewDhcpResetRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/reset") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDhcpResetLeasesRequest generates requests for DhcpResetLeases +func NewDhcpResetLeasesRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/reset_leases") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDhcpSetConfigRequest calls the generic DhcpSetConfig builder with application/json body +func NewDhcpSetConfigRequest(server string, body DhcpSetConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewDhcpSetConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewDhcpSetConfigRequestWithBody generates requests for DhcpSetConfig with any type of body +func NewDhcpSetConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/set_config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDhcpStatusRequest generates requests for DhcpStatus +func NewDhcpStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewDhcpUpdateStaticLeaseRequest calls the generic DhcpUpdateStaticLease builder with application/json body +func NewDhcpUpdateStaticLeaseRequest(server string, body DhcpUpdateStaticLeaseJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewDhcpUpdateStaticLeaseRequestWithBody(server, "application/json", bodyReader) +} + +// NewDhcpUpdateStaticLeaseRequestWithBody generates requests for DhcpUpdateStaticLease with any type of body +func NewDhcpUpdateStaticLeaseRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dhcp/update_static_lease") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDnsConfigRequest calls the generic DnsConfig builder with application/json body +func NewDnsConfigRequest(server string, body DnsConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewDnsConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewDnsConfigRequestWithBody generates requests for DnsConfig with any type of body +func NewDnsConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dns_config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDnsInfoRequest generates requests for DnsInfo +func NewDnsInfoRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/dns_info") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewFilteringAddURLRequest calls the generic FilteringAddURL builder with application/json body +func NewFilteringAddURLRequest(server string, body FilteringAddURLJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewFilteringAddURLRequestWithBody(server, "application/json", bodyReader) +} + +// NewFilteringAddURLRequestWithBody generates requests for FilteringAddURL with any type of body +func NewFilteringAddURLRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/add_url") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewFilteringCheckHostRequest generates requests for FilteringCheckHost +func NewFilteringCheckHostRequest(server string, params *FilteringCheckHostParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/check_host") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.Name != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "name", runtime.ParamLocationQuery, *params.Name); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewFilteringConfigRequest calls the generic FilteringConfig builder with application/json body +func NewFilteringConfigRequest(server string, body FilteringConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewFilteringConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewFilteringConfigRequestWithBody generates requests for FilteringConfig with any type of body +func NewFilteringConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewFilteringRefreshRequest calls the generic FilteringRefresh builder with application/json body +func NewFilteringRefreshRequest(server string, body FilteringRefreshJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewFilteringRefreshRequestWithBody(server, "application/json", bodyReader) +} + +// NewFilteringRefreshRequestWithBody generates requests for FilteringRefresh with any type of body +func NewFilteringRefreshRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/refresh") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewFilteringRemoveURLRequest calls the generic FilteringRemoveURL builder with application/json body +func NewFilteringRemoveURLRequest(server string, body FilteringRemoveURLJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewFilteringRemoveURLRequestWithBody(server, "application/json", bodyReader) +} + +// NewFilteringRemoveURLRequestWithBody generates requests for FilteringRemoveURL with any type of body +func NewFilteringRemoveURLRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/remove_url") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewFilteringSetRulesRequest calls the generic FilteringSetRules builder with application/json body +func NewFilteringSetRulesRequest(server string, body FilteringSetRulesJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewFilteringSetRulesRequestWithBody(server, "application/json", bodyReader) +} + +// NewFilteringSetRulesRequestWithBody generates requests for FilteringSetRules with any type of body +func NewFilteringSetRulesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/set_rules") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewFilteringSetURLRequest calls the generic FilteringSetURL builder with application/json body +func NewFilteringSetURLRequest(server string, body FilteringSetURLJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewFilteringSetURLRequestWithBody(server, "application/json", bodyReader) +} + +// NewFilteringSetURLRequestWithBody generates requests for FilteringSetURL with any type of body +func NewFilteringSetURLRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/set_url") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewFilteringStatusRequest generates requests for FilteringStatus +func NewFilteringStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/filtering/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewChangeLanguageRequest calls the generic ChangeLanguage builder with application/json body +func NewChangeLanguageRequest(server string, body ChangeLanguageJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewChangeLanguageRequestWithBody(server, "application/json", bodyReader) +} + +// NewChangeLanguageRequestWithBody generates requests for ChangeLanguage with any type of body +func NewChangeLanguageRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/i18n/change_language") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewCurrentLanguageRequest generates requests for CurrentLanguage +func NewCurrentLanguageRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/i18n/current_language") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewInstallCheckConfigRequest calls the generic InstallCheckConfig builder with application/json body +func NewInstallCheckConfigRequest(server string, body InstallCheckConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewInstallCheckConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewInstallCheckConfigRequestWithBody generates requests for InstallCheckConfig with any type of body +func NewInstallCheckConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/install/check_config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewInstallConfigureRequest calls the generic InstallConfigure builder with application/json body +func NewInstallConfigureRequest(server string, body InstallConfigureJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewInstallConfigureRequestWithBody(server, "application/json", bodyReader) +} + +// NewInstallConfigureRequestWithBody generates requests for InstallConfigure with any type of body +func NewInstallConfigureRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/install/configure") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewInstallGetAddressesRequest generates requests for InstallGetAddresses +func NewInstallGetAddressesRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/install/get_addresses") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewLoginRequest calls the generic Login builder with application/json body +func NewLoginRequest(server string, body LoginJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewLoginRequestWithBody(server, "application/json", bodyReader) +} + +// NewLoginRequestWithBody generates requests for Login with any type of body +func NewLoginRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/login") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewLogoutRequest generates requests for Logout +func NewLogoutRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/logout") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewParentalDisableRequest generates requests for ParentalDisable +func NewParentalDisableRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/parental/disable") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewParentalEnableRequest generates requests for ParentalEnable +func NewParentalEnableRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/parental/enable") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewParentalStatusRequest generates requests for ParentalStatus +func NewParentalStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/parental/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetProfileRequest generates requests for GetProfile +func NewGetProfileRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/profile") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateProfileRequest calls the generic UpdateProfile builder with application/json body +func NewUpdateProfileRequest(server string, body UpdateProfileJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateProfileRequestWithBody(server, "application/json", bodyReader) +} + +// NewUpdateProfileRequestWithBody generates requests for UpdateProfile with any type of body +func NewUpdateProfileRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/profile/update") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSetProtectionRequest calls the generic SetProtection builder with application/json body +func NewSetProtectionRequest(server string, body SetProtectionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSetProtectionRequestWithBody(server, "application/json", bodyReader) +} + +// NewSetProtectionRequestWithBody generates requests for SetProtection with any type of body +func NewSetProtectionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/protection") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewQueryLogRequest generates requests for QueryLog +func NewQueryLogRequest(server string, params *QueryLogParams) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/querylog") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.OlderThan != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "older_than", runtime.ParamLocationQuery, *params.OlderThan); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Offset != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Search != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "search", runtime.ParamLocationQuery, *params.Search); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.ResponseStatus != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "response_status", runtime.ParamLocationQuery, *params.ResponseStatus); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetQueryLogConfigRequest generates requests for GetQueryLogConfig +func NewGetQueryLogConfigRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/querylog/config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPutQueryLogConfigRequest calls the generic PutQueryLogConfig builder with application/json body +func NewPutQueryLogConfigRequest(server string, body PutQueryLogConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutQueryLogConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutQueryLogConfigRequestWithBody generates requests for PutQueryLogConfig with any type of body +func NewPutQueryLogConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/querylog/config/update") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewQuerylogClearRequest generates requests for QuerylogClear +func NewQuerylogClearRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/querylog_clear") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewQueryLogConfigRequest calls the generic QueryLogConfig builder with application/json body +func NewQueryLogConfigRequest(server string, body QueryLogConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewQueryLogConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewQueryLogConfigRequestWithBody generates requests for QueryLogConfig with any type of body +func NewQueryLogConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/querylog_config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewQueryLogInfoRequest generates requests for QueryLogInfo +func NewQueryLogInfoRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/querylog_info") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRewriteAddRequest calls the generic RewriteAdd builder with application/json body +func NewRewriteAddRequest(server string, body RewriteAddJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRewriteAddRequestWithBody(server, "application/json", bodyReader) +} + +// NewRewriteAddRequestWithBody generates requests for RewriteAdd with any type of body +func NewRewriteAddRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/rewrite/add") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewRewriteDeleteRequest calls the generic RewriteDelete builder with application/json body +func NewRewriteDeleteRequest(server string, body RewriteDeleteJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRewriteDeleteRequestWithBody(server, "application/json", bodyReader) +} + +// NewRewriteDeleteRequestWithBody generates requests for RewriteDelete with any type of body +func NewRewriteDeleteRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/rewrite/delete") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewRewriteListRequest generates requests for RewriteList +func NewRewriteListRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/rewrite/list") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewRewriteUpdateRequest calls the generic RewriteUpdate builder with application/json body +func NewRewriteUpdateRequest(server string, body RewriteUpdateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRewriteUpdateRequestWithBody(server, "application/json", bodyReader) +} + +// NewRewriteUpdateRequestWithBody generates requests for RewriteUpdate with any type of body +func NewRewriteUpdateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/rewrite/update") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSafebrowsingDisableRequest generates requests for SafebrowsingDisable +func NewSafebrowsingDisableRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/safebrowsing/disable") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSafebrowsingEnableRequest generates requests for SafebrowsingEnable +func NewSafebrowsingEnableRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/safebrowsing/enable") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSafebrowsingStatusRequest generates requests for SafebrowsingStatus +func NewSafebrowsingStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/safebrowsing/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSafesearchDisableRequest generates requests for SafesearchDisable +func NewSafesearchDisableRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/safesearch/disable") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSafesearchEnableRequest generates requests for SafesearchEnable +func NewSafesearchEnableRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/safesearch/enable") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewSafesearchSettingsRequest calls the generic SafesearchSettings builder with application/json body +func NewSafesearchSettingsRequest(server string, body SafesearchSettingsJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewSafesearchSettingsRequestWithBody(server, "application/json", bodyReader) +} + +// NewSafesearchSettingsRequestWithBody generates requests for SafesearchSettings with any type of body +func NewSafesearchSettingsRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/safesearch/settings") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewSafesearchStatusRequest generates requests for SafesearchStatus +func NewSafesearchStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/safesearch/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStatsRequest generates requests for Stats +func NewStatsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/stats") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetStatsConfigRequest generates requests for GetStatsConfig +func NewGetStatsConfigRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/stats/config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewPutStatsConfigRequest calls the generic PutStatsConfig builder with application/json body +func NewPutStatsConfigRequest(server string, body PutStatsConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPutStatsConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewPutStatsConfigRequestWithBody generates requests for PutStatsConfig with any type of body +func NewPutStatsConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/stats/config/update") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewStatsConfigRequest calls the generic StatsConfig builder with application/json body +func NewStatsConfigRequest(server string, body StatsConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewStatsConfigRequestWithBody(server, "application/json", bodyReader) +} + +// NewStatsConfigRequestWithBody generates requests for StatsConfig with any type of body +func NewStatsConfigRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/stats_config") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewStatsInfoRequest generates requests for StatsInfo +func NewStatsInfoRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/stats_info") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStatsResetRequest generates requests for StatsReset +func NewStatsResetRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/stats_reset") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewStatusRequest generates requests for Status +func NewStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewTestUpstreamDNSRequest calls the generic TestUpstreamDNS builder with application/json body +func NewTestUpstreamDNSRequest(server string, body TestUpstreamDNSJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewTestUpstreamDNSRequestWithBody(server, "application/json", bodyReader) +} + +// NewTestUpstreamDNSRequestWithBody generates requests for TestUpstreamDNS with any type of body +func NewTestUpstreamDNSRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/test_upstream_dns") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewTlsConfigureRequest calls the generic TlsConfigure builder with application/json body +func NewTlsConfigureRequest(server string, body TlsConfigureJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewTlsConfigureRequestWithBody(server, "application/json", bodyReader) +} + +// NewTlsConfigureRequestWithBody generates requests for TlsConfigure with any type of body +func NewTlsConfigureRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/tls/configure") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewTlsStatusRequest generates requests for TlsStatus +func NewTlsStatusRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/tls/status") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewTlsValidateRequest calls the generic TlsValidate builder with application/json body +func NewTlsValidateRequest(server string, body TlsValidateJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewTlsValidateRequestWithBody(server, "application/json", bodyReader) +} + +// NewTlsValidateRequestWithBody generates requests for TlsValidate with any type of body +func NewTlsValidateRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/tls/validate") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewBeginUpdateRequest generates requests for BeginUpdate +func NewBeginUpdateRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/update") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetVersionJsonRequest calls the generic GetVersionJson builder with application/json body +func NewGetVersionJsonRequest(server string, body GetVersionJsonJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewGetVersionJsonRequestWithBody(server, "application/json", bodyReader) +} + +// NewGetVersionJsonRequestWithBody generates requests for GetVersionJson with any type of body +func NewGetVersionJsonRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/version.json") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +func (c *AdguardHomeClient) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *AdguardHomeClient) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // AccessListWithResponse request + AccessListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccessListResp, error) + + // AccessSetWithBodyWithResponse request with any body + AccessSetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccessSetResp, error) + + AccessSetWithResponse(ctx context.Context, body AccessSetJSONRequestBody, reqEditors ...RequestEditorFn) (*AccessSetResp, error) + + // MobileConfigDoHWithResponse request + MobileConfigDoHWithResponse(ctx context.Context, params *MobileConfigDoHParams, reqEditors ...RequestEditorFn) (*MobileConfigDoHResp, error) + + // MobileConfigDoTWithResponse request + MobileConfigDoTWithResponse(ctx context.Context, params *MobileConfigDoTParams, reqEditors ...RequestEditorFn) (*MobileConfigDoTResp, error) + + // BlockedServicesAllWithResponse request + BlockedServicesAllWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesAllResp, error) + + // BlockedServicesScheduleWithResponse request + BlockedServicesScheduleWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesScheduleResp, error) + + // BlockedServicesListWithResponse request + BlockedServicesListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesListResp, error) + + // BlockedServicesAvailableServicesWithResponse request + BlockedServicesAvailableServicesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesAvailableServicesResp, error) + + // BlockedServicesSetWithBodyWithResponse request with any body + BlockedServicesSetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BlockedServicesSetResp, error) + + BlockedServicesSetWithResponse(ctx context.Context, body BlockedServicesSetJSONRequestBody, reqEditors ...RequestEditorFn) (*BlockedServicesSetResp, error) + + // BlockedServicesScheduleUpdateWithBodyWithResponse request with any body + BlockedServicesScheduleUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BlockedServicesScheduleUpdateResp, error) + + BlockedServicesScheduleUpdateWithResponse(ctx context.Context, body BlockedServicesScheduleUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*BlockedServicesScheduleUpdateResp, error) + + // CacheClearWithResponse request + CacheClearWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CacheClearResp, error) + + // ClientsStatusWithResponse request + ClientsStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ClientsStatusResp, error) + + // ClientsAddWithBodyWithResponse request with any body + ClientsAddWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsAddResp, error) + + ClientsAddWithResponse(ctx context.Context, body ClientsAddJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsAddResp, error) + + // ClientsDeleteWithBodyWithResponse request with any body + ClientsDeleteWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsDeleteResp, error) + + ClientsDeleteWithResponse(ctx context.Context, body ClientsDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsDeleteResp, error) + + // ClientsFindWithResponse request + ClientsFindWithResponse(ctx context.Context, params *ClientsFindParams, reqEditors ...RequestEditorFn) (*ClientsFindResp, error) + + // ClientsUpdateWithBodyWithResponse request with any body + ClientsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsUpdateResp, error) + + ClientsUpdateWithResponse(ctx context.Context, body ClientsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsUpdateResp, error) + + // DhcpAddStaticLeaseWithBodyWithResponse request with any body + DhcpAddStaticLeaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpAddStaticLeaseResp, error) + + DhcpAddStaticLeaseWithResponse(ctx context.Context, body DhcpAddStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpAddStaticLeaseResp, error) + + // CheckActiveDhcpWithBodyWithResponse request with any body + CheckActiveDhcpWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CheckActiveDhcpResp, error) + + CheckActiveDhcpWithResponse(ctx context.Context, body CheckActiveDhcpJSONRequestBody, reqEditors ...RequestEditorFn) (*CheckActiveDhcpResp, error) + + // DhcpInterfacesWithResponse request + DhcpInterfacesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpInterfacesResp, error) + + // DhcpRemoveStaticLeaseWithBodyWithResponse request with any body + DhcpRemoveStaticLeaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpRemoveStaticLeaseResp, error) + + DhcpRemoveStaticLeaseWithResponse(ctx context.Context, body DhcpRemoveStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpRemoveStaticLeaseResp, error) + + // DhcpResetWithResponse request + DhcpResetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpResetResp, error) + + // DhcpResetLeasesWithResponse request + DhcpResetLeasesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpResetLeasesResp, error) + + // DhcpSetConfigWithBodyWithResponse request with any body + DhcpSetConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpSetConfigResp, error) + + DhcpSetConfigWithResponse(ctx context.Context, body DhcpSetConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpSetConfigResp, error) + + // DhcpStatusWithResponse request + DhcpStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpStatusResp, error) + + // DhcpUpdateStaticLeaseWithBodyWithResponse request with any body + DhcpUpdateStaticLeaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpUpdateStaticLeaseResp, error) + + DhcpUpdateStaticLeaseWithResponse(ctx context.Context, body DhcpUpdateStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpUpdateStaticLeaseResp, error) + + // DnsConfigWithBodyWithResponse request with any body + DnsConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DnsConfigResp, error) + + DnsConfigWithResponse(ctx context.Context, body DnsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*DnsConfigResp, error) + + // DnsInfoWithResponse request + DnsInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DnsInfoResp, error) + + // FilteringAddURLWithBodyWithResponse request with any body + FilteringAddURLWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringAddURLResp, error) + + FilteringAddURLWithResponse(ctx context.Context, body FilteringAddURLJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringAddURLResp, error) + + // FilteringCheckHostWithResponse request + FilteringCheckHostWithResponse(ctx context.Context, params *FilteringCheckHostParams, reqEditors ...RequestEditorFn) (*FilteringCheckHostResp, error) + + // FilteringConfigWithBodyWithResponse request with any body + FilteringConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringConfigResp, error) + + FilteringConfigWithResponse(ctx context.Context, body FilteringConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringConfigResp, error) + + // FilteringRefreshWithBodyWithResponse request with any body + FilteringRefreshWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringRefreshResp, error) + + FilteringRefreshWithResponse(ctx context.Context, body FilteringRefreshJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringRefreshResp, error) + + // FilteringRemoveURLWithBodyWithResponse request with any body + FilteringRemoveURLWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringRemoveURLResp, error) + + FilteringRemoveURLWithResponse(ctx context.Context, body FilteringRemoveURLJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringRemoveURLResp, error) + + // FilteringSetRulesWithBodyWithResponse request with any body + FilteringSetRulesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringSetRulesResp, error) + + FilteringSetRulesWithResponse(ctx context.Context, body FilteringSetRulesJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringSetRulesResp, error) + + // FilteringSetURLWithBodyWithResponse request with any body + FilteringSetURLWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringSetURLResp, error) + + FilteringSetURLWithResponse(ctx context.Context, body FilteringSetURLJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringSetURLResp, error) + + // FilteringStatusWithResponse request + FilteringStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*FilteringStatusResp, error) + + // ChangeLanguageWithBodyWithResponse request with any body + ChangeLanguageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ChangeLanguageResp, error) + + ChangeLanguageWithResponse(ctx context.Context, body ChangeLanguageJSONRequestBody, reqEditors ...RequestEditorFn) (*ChangeLanguageResp, error) + + // CurrentLanguageWithResponse request + CurrentLanguageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CurrentLanguageResp, error) + + // InstallCheckConfigWithBodyWithResponse request with any body + InstallCheckConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*InstallCheckConfigResp, error) + + InstallCheckConfigWithResponse(ctx context.Context, body InstallCheckConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*InstallCheckConfigResp, error) + + // InstallConfigureWithBodyWithResponse request with any body + InstallConfigureWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*InstallConfigureResp, error) + + InstallConfigureWithResponse(ctx context.Context, body InstallConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*InstallConfigureResp, error) + + // InstallGetAddressesWithResponse request + InstallGetAddressesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*InstallGetAddressesResp, error) + + // LoginWithBodyWithResponse request with any body + LoginWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LoginResp, error) + + LoginWithResponse(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*LoginResp, error) + + // LogoutWithResponse request + LogoutWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*LogoutResp, error) + + // ParentalDisableWithResponse request + ParentalDisableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ParentalDisableResp, error) + + // ParentalEnableWithResponse request + ParentalEnableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ParentalEnableResp, error) + + // ParentalStatusWithResponse request + ParentalStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ParentalStatusResp, error) + + // GetProfileWithResponse request + GetProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileResp, error) + + // UpdateProfileWithBodyWithResponse request with any body + UpdateProfileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProfileResp, error) + + UpdateProfileWithResponse(ctx context.Context, body UpdateProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProfileResp, error) + + // SetProtectionWithBodyWithResponse request with any body + SetProtectionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetProtectionResp, error) + + SetProtectionWithResponse(ctx context.Context, body SetProtectionJSONRequestBody, reqEditors ...RequestEditorFn) (*SetProtectionResp, error) + + // QueryLogWithResponse request + QueryLogWithResponse(ctx context.Context, params *QueryLogParams, reqEditors ...RequestEditorFn) (*QueryLogResp, error) + + // GetQueryLogConfigWithResponse request + GetQueryLogConfigWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetQueryLogConfigResp, error) + + // PutQueryLogConfigWithBodyWithResponse request with any body + PutQueryLogConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutQueryLogConfigResp, error) + + PutQueryLogConfigWithResponse(ctx context.Context, body PutQueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*PutQueryLogConfigResp, error) + + // QuerylogClearWithResponse request + QuerylogClearWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*QuerylogClearResp, error) + + // QueryLogConfigWithBodyWithResponse request with any body + QueryLogConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*QueryLogConfigResp, error) + + QueryLogConfigWithResponse(ctx context.Context, body QueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*QueryLogConfigResp, error) + + // QueryLogInfoWithResponse request + QueryLogInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*QueryLogInfoResp, error) + + // RewriteAddWithBodyWithResponse request with any body + RewriteAddWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewriteAddResp, error) + + RewriteAddWithResponse(ctx context.Context, body RewriteAddJSONRequestBody, reqEditors ...RequestEditorFn) (*RewriteAddResp, error) + + // RewriteDeleteWithBodyWithResponse request with any body + RewriteDeleteWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewriteDeleteResp, error) + + RewriteDeleteWithResponse(ctx context.Context, body RewriteDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*RewriteDeleteResp, error) + + // RewriteListWithResponse request + RewriteListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RewriteListResp, error) + + // RewriteUpdateWithBodyWithResponse request with any body + RewriteUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewriteUpdateResp, error) + + RewriteUpdateWithResponse(ctx context.Context, body RewriteUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*RewriteUpdateResp, error) + + // SafebrowsingDisableWithResponse request + SafebrowsingDisableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafebrowsingDisableResp, error) + + // SafebrowsingEnableWithResponse request + SafebrowsingEnableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafebrowsingEnableResp, error) + + // SafebrowsingStatusWithResponse request + SafebrowsingStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafebrowsingStatusResp, error) + + // SafesearchDisableWithResponse request + SafesearchDisableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafesearchDisableResp, error) + + // SafesearchEnableWithResponse request + SafesearchEnableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafesearchEnableResp, error) + + // SafesearchSettingsWithBodyWithResponse request with any body + SafesearchSettingsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SafesearchSettingsResp, error) + + SafesearchSettingsWithResponse(ctx context.Context, body SafesearchSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*SafesearchSettingsResp, error) + + // SafesearchStatusWithResponse request + SafesearchStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafesearchStatusResp, error) + + // StatsWithResponse request + StatsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatsResp, error) + + // GetStatsConfigWithResponse request + GetStatsConfigWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetStatsConfigResp, error) + + // PutStatsConfigWithBodyWithResponse request with any body + PutStatsConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutStatsConfigResp, error) + + PutStatsConfigWithResponse(ctx context.Context, body PutStatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*PutStatsConfigResp, error) + + // StatsConfigWithBodyWithResponse request with any body + StatsConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*StatsConfigResp, error) + + StatsConfigWithResponse(ctx context.Context, body StatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*StatsConfigResp, error) + + // StatsInfoWithResponse request + StatsInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatsInfoResp, error) + + // StatsResetWithResponse request + StatsResetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatsResetResp, error) + + // StatusWithResponse request + StatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatusResp, error) + + // TestUpstreamDNSWithBodyWithResponse request with any body + TestUpstreamDNSWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TestUpstreamDNSResp, error) + + TestUpstreamDNSWithResponse(ctx context.Context, body TestUpstreamDNSJSONRequestBody, reqEditors ...RequestEditorFn) (*TestUpstreamDNSResp, error) + + // TlsConfigureWithBodyWithResponse request with any body + TlsConfigureWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TlsConfigureResp, error) + + TlsConfigureWithResponse(ctx context.Context, body TlsConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*TlsConfigureResp, error) + + // TlsStatusWithResponse request + TlsStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*TlsStatusResp, error) + + // TlsValidateWithBodyWithResponse request with any body + TlsValidateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TlsValidateResp, error) + + TlsValidateWithResponse(ctx context.Context, body TlsValidateJSONRequestBody, reqEditors ...RequestEditorFn) (*TlsValidateResp, error) + + // BeginUpdateWithResponse request + BeginUpdateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BeginUpdateResp, error) + + // GetVersionJsonWithBodyWithResponse request with any body + GetVersionJsonWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetVersionJsonResp, error) + + GetVersionJsonWithResponse(ctx context.Context, body GetVersionJsonJSONRequestBody, reqEditors ...RequestEditorFn) (*GetVersionJsonResp, error) +} + +type AccessListResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AccessListResponse +} + +// Status returns HTTPResponse.Status +func (r AccessListResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AccessListResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type AccessSetResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r AccessSetResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r AccessSetResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type MobileConfigDoHResp struct { + Body []byte + HTTPResponse *http.Response + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r MobileConfigDoHResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r MobileConfigDoHResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type MobileConfigDoTResp struct { + Body []byte + HTTPResponse *http.Response + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r MobileConfigDoTResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r MobileConfigDoTResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BlockedServicesAllResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *BlockedServicesAll +} + +// Status returns HTTPResponse.Status +func (r BlockedServicesAllResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BlockedServicesAllResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BlockedServicesScheduleResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *BlockedServicesSchedule +} + +// Status returns HTTPResponse.Status +func (r BlockedServicesScheduleResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BlockedServicesScheduleResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BlockedServicesListResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *BlockedServicesArray +} + +// Status returns HTTPResponse.Status +func (r BlockedServicesListResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BlockedServicesListResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BlockedServicesAvailableServicesResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *BlockedServicesArray +} + +// Status returns HTTPResponse.Status +func (r BlockedServicesAvailableServicesResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BlockedServicesAvailableServicesResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BlockedServicesSetResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r BlockedServicesSetResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BlockedServicesSetResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BlockedServicesScheduleUpdateResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r BlockedServicesScheduleUpdateResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BlockedServicesScheduleUpdateResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CacheClearResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r CacheClearResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CacheClearResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClientsStatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Clients +} + +// Status returns HTTPResponse.Status +func (r ClientsStatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClientsStatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClientsAddResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ClientsAddResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClientsAddResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClientsDeleteResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ClientsDeleteResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClientsDeleteResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClientsFindResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ClientsFindResponse +} + +// Status returns HTTPResponse.Status +func (r ClientsFindResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClientsFindResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ClientsUpdateResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ClientsUpdateResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ClientsUpdateResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpAddStaticLeaseResp struct { + Body []byte + HTTPResponse *http.Response + JSON501 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpAddStaticLeaseResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpAddStaticLeaseResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CheckActiveDhcpResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DhcpSearchResult + JSON501 *Error +} + +// Status returns HTTPResponse.Status +func (r CheckActiveDhcpResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CheckActiveDhcpResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpInterfacesResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *NetInterfaces + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpInterfacesResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpInterfacesResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpRemoveStaticLeaseResp struct { + Body []byte + HTTPResponse *http.Response + JSON501 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpRemoveStaticLeaseResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpRemoveStaticLeaseResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpResetResp struct { + Body []byte + HTTPResponse *http.Response + JSON501 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpResetResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpResetResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpResetLeasesResp struct { + Body []byte + HTTPResponse *http.Response + JSON501 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpResetLeasesResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpResetLeasesResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpSetConfigResp struct { + Body []byte + HTTPResponse *http.Response + JSON501 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpSetConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpSetConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpStatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DhcpStatus + JSON500 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpStatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpStatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DhcpUpdateStaticLeaseResp struct { + Body []byte + HTTPResponse *http.Response + JSON501 *Error +} + +// Status returns HTTPResponse.Status +func (r DhcpUpdateStaticLeaseResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DhcpUpdateStaticLeaseResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DnsConfigResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r DnsConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DnsConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DnsInfoResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *DNSConfig +} + +// Status returns HTTPResponse.Status +func (r DnsInfoResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DnsInfoResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringAddURLResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r FilteringAddURLResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringAddURLResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringCheckHostResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FilterCheckHostResponse +} + +// Status returns HTTPResponse.Status +func (r FilteringCheckHostResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringCheckHostResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringConfigResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r FilteringConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringRefreshResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FilterRefreshResponse +} + +// Status returns HTTPResponse.Status +func (r FilteringRefreshResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringRefreshResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringRemoveURLResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r FilteringRemoveURLResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringRemoveURLResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringSetRulesResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r FilteringSetRulesResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringSetRulesResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringSetURLResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r FilteringSetURLResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringSetURLResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type FilteringStatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *FilterStatus +} + +// Status returns HTTPResponse.Status +func (r FilteringStatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FilteringStatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ChangeLanguageResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ChangeLanguageResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ChangeLanguageResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CurrentLanguageResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *LanguageSettings +} + +// Status returns HTTPResponse.Status +func (r CurrentLanguageResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CurrentLanguageResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type InstallCheckConfigResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *CheckConfigResponse +} + +// Status returns HTTPResponse.Status +func (r InstallCheckConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r InstallCheckConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type InstallConfigureResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r InstallConfigureResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r InstallConfigureResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type InstallGetAddressesResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AddressesInfo +} + +// Status returns HTTPResponse.Status +func (r InstallGetAddressesResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r InstallGetAddressesResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LoginResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r LoginResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LoginResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LogoutResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r LogoutResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LogoutResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ParentalDisableResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ParentalDisableResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ParentalDisableResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ParentalEnableResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r ParentalEnableResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ParentalEnableResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ParentalStatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Enable *bool `json:"enable,omitempty"` + Sensitivity *int `json:"sensitivity,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r ParentalStatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ParentalStatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetProfileResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ProfileInfo +} + +// Status returns HTTPResponse.Status +func (r GetProfileResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetProfileResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateProfileResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r UpdateProfileResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateProfileResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SetProtectionResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r SetProtectionResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SetProtectionResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type QueryLogResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *QueryLog +} + +// Status returns HTTPResponse.Status +func (r QueryLogResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r QueryLogResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetQueryLogConfigResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *GetQueryLogConfigResponse +} + +// Status returns HTTPResponse.Status +func (r GetQueryLogConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetQueryLogConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutQueryLogConfigResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutQueryLogConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutQueryLogConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type QuerylogClearResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r QuerylogClearResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r QuerylogClearResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type QueryLogConfigResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r QueryLogConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r QueryLogConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type QueryLogInfoResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *QueryLogConfig +} + +// Status returns HTTPResponse.Status +func (r QueryLogInfoResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r QueryLogInfoResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type RewriteAddResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r RewriteAddResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RewriteAddResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type RewriteDeleteResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r RewriteDeleteResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RewriteDeleteResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type RewriteListResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *RewriteList +} + +// Status returns HTTPResponse.Status +func (r RewriteListResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RewriteListResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type RewriteUpdateResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r RewriteUpdateResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RewriteUpdateResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SafebrowsingDisableResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r SafebrowsingDisableResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SafebrowsingDisableResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SafebrowsingEnableResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r SafebrowsingEnableResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SafebrowsingEnableResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SafebrowsingStatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Enabled *bool `json:"enabled,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r SafebrowsingStatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SafebrowsingStatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SafesearchDisableResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r SafesearchDisableResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SafesearchDisableResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SafesearchEnableResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r SafesearchEnableResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SafesearchEnableResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SafesearchSettingsResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r SafesearchSettingsResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SafesearchSettingsResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type SafesearchStatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *SafeSearchConfig +} + +// Status returns HTTPResponse.Status +func (r SafesearchStatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r SafesearchStatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type StatsResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Stats +} + +// Status returns HTTPResponse.Status +func (r StatsResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StatsResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetStatsConfigResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *GetStatsConfigResponse +} + +// Status returns HTTPResponse.Status +func (r GetStatsConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetStatsConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PutStatsConfigResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r PutStatsConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PutStatsConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type StatsConfigResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r StatsConfigResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StatsConfigResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type StatsInfoResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *StatsConfig +} + +// Status returns HTTPResponse.Status +func (r StatsInfoResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StatsInfoResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type StatsResetResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r StatsResetResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StatsResetResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type StatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ServerStatus +} + +// Status returns HTTPResponse.Status +func (r StatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r StatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type TestUpstreamDNSResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *UpstreamsConfigResponse +} + +// Status returns HTTPResponse.Status +func (r TestUpstreamDNSResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TestUpstreamDNSResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type TlsConfigureResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *TlsConfig +} + +// Status returns HTTPResponse.Status +func (r TlsConfigureResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TlsConfigureResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type TlsStatusResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *TlsConfig +} + +// Status returns HTTPResponse.Status +func (r TlsStatusResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TlsStatusResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type TlsValidateResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *TlsConfig +} + +// Status returns HTTPResponse.Status +func (r TlsValidateResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r TlsValidateResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type BeginUpdateResp struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r BeginUpdateResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r BeginUpdateResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetVersionJsonResp struct { + Body []byte + HTTPResponse *http.Response + JSON200 *VersionInfo +} + +// Status returns HTTPResponse.Status +func (r GetVersionJsonResp) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetVersionJsonResp) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// AccessListWithResponse request returning *AccessListResp +func (c *ClientWithResponses) AccessListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*AccessListResp, error) { + rsp, err := c.AccessList(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccessListResp(rsp) +} + +// AccessSetWithBodyWithResponse request with arbitrary body returning *AccessSetResp +func (c *ClientWithResponses) AccessSetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AccessSetResp, error) { + rsp, err := c.AccessSetWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccessSetResp(rsp) +} + +func (c *ClientWithResponses) AccessSetWithResponse(ctx context.Context, body AccessSetJSONRequestBody, reqEditors ...RequestEditorFn) (*AccessSetResp, error) { + rsp, err := c.AccessSet(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAccessSetResp(rsp) +} + +// MobileConfigDoHWithResponse request returning *MobileConfigDoHResp +func (c *ClientWithResponses) MobileConfigDoHWithResponse(ctx context.Context, params *MobileConfigDoHParams, reqEditors ...RequestEditorFn) (*MobileConfigDoHResp, error) { + rsp, err := c.MobileConfigDoH(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseMobileConfigDoHResp(rsp) +} + +// MobileConfigDoTWithResponse request returning *MobileConfigDoTResp +func (c *ClientWithResponses) MobileConfigDoTWithResponse(ctx context.Context, params *MobileConfigDoTParams, reqEditors ...RequestEditorFn) (*MobileConfigDoTResp, error) { + rsp, err := c.MobileConfigDoT(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseMobileConfigDoTResp(rsp) +} + +// BlockedServicesAllWithResponse request returning *BlockedServicesAllResp +func (c *ClientWithResponses) BlockedServicesAllWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesAllResp, error) { + rsp, err := c.BlockedServicesAll(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesAllResp(rsp) +} + +// BlockedServicesScheduleWithResponse request returning *BlockedServicesScheduleResp +func (c *ClientWithResponses) BlockedServicesScheduleWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesScheduleResp, error) { + rsp, err := c.BlockedServicesSchedule(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesScheduleResp(rsp) +} + +// BlockedServicesListWithResponse request returning *BlockedServicesListResp +func (c *ClientWithResponses) BlockedServicesListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesListResp, error) { + rsp, err := c.BlockedServicesList(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesListResp(rsp) +} + +// BlockedServicesAvailableServicesWithResponse request returning *BlockedServicesAvailableServicesResp +func (c *ClientWithResponses) BlockedServicesAvailableServicesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BlockedServicesAvailableServicesResp, error) { + rsp, err := c.BlockedServicesAvailableServices(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesAvailableServicesResp(rsp) +} + +// BlockedServicesSetWithBodyWithResponse request with arbitrary body returning *BlockedServicesSetResp +func (c *ClientWithResponses) BlockedServicesSetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BlockedServicesSetResp, error) { + rsp, err := c.BlockedServicesSetWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesSetResp(rsp) +} + +func (c *ClientWithResponses) BlockedServicesSetWithResponse(ctx context.Context, body BlockedServicesSetJSONRequestBody, reqEditors ...RequestEditorFn) (*BlockedServicesSetResp, error) { + rsp, err := c.BlockedServicesSet(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesSetResp(rsp) +} + +// BlockedServicesScheduleUpdateWithBodyWithResponse request with arbitrary body returning *BlockedServicesScheduleUpdateResp +func (c *ClientWithResponses) BlockedServicesScheduleUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*BlockedServicesScheduleUpdateResp, error) { + rsp, err := c.BlockedServicesScheduleUpdateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesScheduleUpdateResp(rsp) +} + +func (c *ClientWithResponses) BlockedServicesScheduleUpdateWithResponse(ctx context.Context, body BlockedServicesScheduleUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*BlockedServicesScheduleUpdateResp, error) { + rsp, err := c.BlockedServicesScheduleUpdate(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseBlockedServicesScheduleUpdateResp(rsp) +} + +// CacheClearWithResponse request returning *CacheClearResp +func (c *ClientWithResponses) CacheClearWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CacheClearResp, error) { + rsp, err := c.CacheClear(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseCacheClearResp(rsp) +} + +// ClientsStatusWithResponse request returning *ClientsStatusResp +func (c *ClientWithResponses) ClientsStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ClientsStatusResp, error) { + rsp, err := c.ClientsStatus(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsStatusResp(rsp) +} + +// ClientsAddWithBodyWithResponse request with arbitrary body returning *ClientsAddResp +func (c *ClientWithResponses) ClientsAddWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsAddResp, error) { + rsp, err := c.ClientsAddWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsAddResp(rsp) +} + +func (c *ClientWithResponses) ClientsAddWithResponse(ctx context.Context, body ClientsAddJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsAddResp, error) { + rsp, err := c.ClientsAdd(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsAddResp(rsp) +} + +// ClientsDeleteWithBodyWithResponse request with arbitrary body returning *ClientsDeleteResp +func (c *ClientWithResponses) ClientsDeleteWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsDeleteResp, error) { + rsp, err := c.ClientsDeleteWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsDeleteResp(rsp) +} + +func (c *ClientWithResponses) ClientsDeleteWithResponse(ctx context.Context, body ClientsDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsDeleteResp, error) { + rsp, err := c.ClientsDelete(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsDeleteResp(rsp) +} + +// ClientsFindWithResponse request returning *ClientsFindResp +func (c *ClientWithResponses) ClientsFindWithResponse(ctx context.Context, params *ClientsFindParams, reqEditors ...RequestEditorFn) (*ClientsFindResp, error) { + rsp, err := c.ClientsFind(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsFindResp(rsp) +} + +// ClientsUpdateWithBodyWithResponse request with arbitrary body returning *ClientsUpdateResp +func (c *ClientWithResponses) ClientsUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ClientsUpdateResp, error) { + rsp, err := c.ClientsUpdateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsUpdateResp(rsp) +} + +func (c *ClientWithResponses) ClientsUpdateWithResponse(ctx context.Context, body ClientsUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*ClientsUpdateResp, error) { + rsp, err := c.ClientsUpdate(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseClientsUpdateResp(rsp) +} + +// DhcpAddStaticLeaseWithBodyWithResponse request with arbitrary body returning *DhcpAddStaticLeaseResp +func (c *ClientWithResponses) DhcpAddStaticLeaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpAddStaticLeaseResp, error) { + rsp, err := c.DhcpAddStaticLeaseWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpAddStaticLeaseResp(rsp) +} + +func (c *ClientWithResponses) DhcpAddStaticLeaseWithResponse(ctx context.Context, body DhcpAddStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpAddStaticLeaseResp, error) { + rsp, err := c.DhcpAddStaticLease(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpAddStaticLeaseResp(rsp) +} + +// CheckActiveDhcpWithBodyWithResponse request with arbitrary body returning *CheckActiveDhcpResp +func (c *ClientWithResponses) CheckActiveDhcpWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CheckActiveDhcpResp, error) { + rsp, err := c.CheckActiveDhcpWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCheckActiveDhcpResp(rsp) +} + +func (c *ClientWithResponses) CheckActiveDhcpWithResponse(ctx context.Context, body CheckActiveDhcpJSONRequestBody, reqEditors ...RequestEditorFn) (*CheckActiveDhcpResp, error) { + rsp, err := c.CheckActiveDhcp(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCheckActiveDhcpResp(rsp) +} + +// DhcpInterfacesWithResponse request returning *DhcpInterfacesResp +func (c *ClientWithResponses) DhcpInterfacesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpInterfacesResp, error) { + rsp, err := c.DhcpInterfaces(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpInterfacesResp(rsp) +} + +// DhcpRemoveStaticLeaseWithBodyWithResponse request with arbitrary body returning *DhcpRemoveStaticLeaseResp +func (c *ClientWithResponses) DhcpRemoveStaticLeaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpRemoveStaticLeaseResp, error) { + rsp, err := c.DhcpRemoveStaticLeaseWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpRemoveStaticLeaseResp(rsp) +} + +func (c *ClientWithResponses) DhcpRemoveStaticLeaseWithResponse(ctx context.Context, body DhcpRemoveStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpRemoveStaticLeaseResp, error) { + rsp, err := c.DhcpRemoveStaticLease(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpRemoveStaticLeaseResp(rsp) +} + +// DhcpResetWithResponse request returning *DhcpResetResp +func (c *ClientWithResponses) DhcpResetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpResetResp, error) { + rsp, err := c.DhcpReset(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpResetResp(rsp) +} + +// DhcpResetLeasesWithResponse request returning *DhcpResetLeasesResp +func (c *ClientWithResponses) DhcpResetLeasesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpResetLeasesResp, error) { + rsp, err := c.DhcpResetLeases(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpResetLeasesResp(rsp) +} + +// DhcpSetConfigWithBodyWithResponse request with arbitrary body returning *DhcpSetConfigResp +func (c *ClientWithResponses) DhcpSetConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpSetConfigResp, error) { + rsp, err := c.DhcpSetConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpSetConfigResp(rsp) +} + +func (c *ClientWithResponses) DhcpSetConfigWithResponse(ctx context.Context, body DhcpSetConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpSetConfigResp, error) { + rsp, err := c.DhcpSetConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpSetConfigResp(rsp) +} + +// DhcpStatusWithResponse request returning *DhcpStatusResp +func (c *ClientWithResponses) DhcpStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DhcpStatusResp, error) { + rsp, err := c.DhcpStatus(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpStatusResp(rsp) +} + +// DhcpUpdateStaticLeaseWithBodyWithResponse request with arbitrary body returning *DhcpUpdateStaticLeaseResp +func (c *ClientWithResponses) DhcpUpdateStaticLeaseWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DhcpUpdateStaticLeaseResp, error) { + rsp, err := c.DhcpUpdateStaticLeaseWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpUpdateStaticLeaseResp(rsp) +} + +func (c *ClientWithResponses) DhcpUpdateStaticLeaseWithResponse(ctx context.Context, body DhcpUpdateStaticLeaseJSONRequestBody, reqEditors ...RequestEditorFn) (*DhcpUpdateStaticLeaseResp, error) { + rsp, err := c.DhcpUpdateStaticLease(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDhcpUpdateStaticLeaseResp(rsp) +} + +// DnsConfigWithBodyWithResponse request with arbitrary body returning *DnsConfigResp +func (c *ClientWithResponses) DnsConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*DnsConfigResp, error) { + rsp, err := c.DnsConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDnsConfigResp(rsp) +} + +func (c *ClientWithResponses) DnsConfigWithResponse(ctx context.Context, body DnsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*DnsConfigResp, error) { + rsp, err := c.DnsConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseDnsConfigResp(rsp) +} + +// DnsInfoWithResponse request returning *DnsInfoResp +func (c *ClientWithResponses) DnsInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DnsInfoResp, error) { + rsp, err := c.DnsInfo(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseDnsInfoResp(rsp) +} + +// FilteringAddURLWithBodyWithResponse request with arbitrary body returning *FilteringAddURLResp +func (c *ClientWithResponses) FilteringAddURLWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringAddURLResp, error) { + rsp, err := c.FilteringAddURLWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringAddURLResp(rsp) +} + +func (c *ClientWithResponses) FilteringAddURLWithResponse(ctx context.Context, body FilteringAddURLJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringAddURLResp, error) { + rsp, err := c.FilteringAddURL(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringAddURLResp(rsp) +} + +// FilteringCheckHostWithResponse request returning *FilteringCheckHostResp +func (c *ClientWithResponses) FilteringCheckHostWithResponse(ctx context.Context, params *FilteringCheckHostParams, reqEditors ...RequestEditorFn) (*FilteringCheckHostResp, error) { + rsp, err := c.FilteringCheckHost(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringCheckHostResp(rsp) +} + +// FilteringConfigWithBodyWithResponse request with arbitrary body returning *FilteringConfigResp +func (c *ClientWithResponses) FilteringConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringConfigResp, error) { + rsp, err := c.FilteringConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringConfigResp(rsp) +} + +func (c *ClientWithResponses) FilteringConfigWithResponse(ctx context.Context, body FilteringConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringConfigResp, error) { + rsp, err := c.FilteringConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringConfigResp(rsp) +} + +// FilteringRefreshWithBodyWithResponse request with arbitrary body returning *FilteringRefreshResp +func (c *ClientWithResponses) FilteringRefreshWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringRefreshResp, error) { + rsp, err := c.FilteringRefreshWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringRefreshResp(rsp) +} + +func (c *ClientWithResponses) FilteringRefreshWithResponse(ctx context.Context, body FilteringRefreshJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringRefreshResp, error) { + rsp, err := c.FilteringRefresh(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringRefreshResp(rsp) +} + +// FilteringRemoveURLWithBodyWithResponse request with arbitrary body returning *FilteringRemoveURLResp +func (c *ClientWithResponses) FilteringRemoveURLWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringRemoveURLResp, error) { + rsp, err := c.FilteringRemoveURLWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringRemoveURLResp(rsp) +} + +func (c *ClientWithResponses) FilteringRemoveURLWithResponse(ctx context.Context, body FilteringRemoveURLJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringRemoveURLResp, error) { + rsp, err := c.FilteringRemoveURL(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringRemoveURLResp(rsp) +} + +// FilteringSetRulesWithBodyWithResponse request with arbitrary body returning *FilteringSetRulesResp +func (c *ClientWithResponses) FilteringSetRulesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringSetRulesResp, error) { + rsp, err := c.FilteringSetRulesWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringSetRulesResp(rsp) +} + +func (c *ClientWithResponses) FilteringSetRulesWithResponse(ctx context.Context, body FilteringSetRulesJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringSetRulesResp, error) { + rsp, err := c.FilteringSetRules(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringSetRulesResp(rsp) +} + +// FilteringSetURLWithBodyWithResponse request with arbitrary body returning *FilteringSetURLResp +func (c *ClientWithResponses) FilteringSetURLWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*FilteringSetURLResp, error) { + rsp, err := c.FilteringSetURLWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringSetURLResp(rsp) +} + +func (c *ClientWithResponses) FilteringSetURLWithResponse(ctx context.Context, body FilteringSetURLJSONRequestBody, reqEditors ...RequestEditorFn) (*FilteringSetURLResp, error) { + rsp, err := c.FilteringSetURL(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringSetURLResp(rsp) +} + +// FilteringStatusWithResponse request returning *FilteringStatusResp +func (c *ClientWithResponses) FilteringStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*FilteringStatusResp, error) { + rsp, err := c.FilteringStatus(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseFilteringStatusResp(rsp) +} + +// ChangeLanguageWithBodyWithResponse request with arbitrary body returning *ChangeLanguageResp +func (c *ClientWithResponses) ChangeLanguageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ChangeLanguageResp, error) { + rsp, err := c.ChangeLanguageWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseChangeLanguageResp(rsp) +} + +func (c *ClientWithResponses) ChangeLanguageWithResponse(ctx context.Context, body ChangeLanguageJSONRequestBody, reqEditors ...RequestEditorFn) (*ChangeLanguageResp, error) { + rsp, err := c.ChangeLanguage(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseChangeLanguageResp(rsp) +} + +// CurrentLanguageWithResponse request returning *CurrentLanguageResp +func (c *ClientWithResponses) CurrentLanguageWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*CurrentLanguageResp, error) { + rsp, err := c.CurrentLanguage(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseCurrentLanguageResp(rsp) +} + +// InstallCheckConfigWithBodyWithResponse request with arbitrary body returning *InstallCheckConfigResp +func (c *ClientWithResponses) InstallCheckConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*InstallCheckConfigResp, error) { + rsp, err := c.InstallCheckConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseInstallCheckConfigResp(rsp) +} + +func (c *ClientWithResponses) InstallCheckConfigWithResponse(ctx context.Context, body InstallCheckConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*InstallCheckConfigResp, error) { + rsp, err := c.InstallCheckConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseInstallCheckConfigResp(rsp) +} + +// InstallConfigureWithBodyWithResponse request with arbitrary body returning *InstallConfigureResp +func (c *ClientWithResponses) InstallConfigureWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*InstallConfigureResp, error) { + rsp, err := c.InstallConfigureWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseInstallConfigureResp(rsp) +} + +func (c *ClientWithResponses) InstallConfigureWithResponse(ctx context.Context, body InstallConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*InstallConfigureResp, error) { + rsp, err := c.InstallConfigure(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseInstallConfigureResp(rsp) +} + +// InstallGetAddressesWithResponse request returning *InstallGetAddressesResp +func (c *ClientWithResponses) InstallGetAddressesWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*InstallGetAddressesResp, error) { + rsp, err := c.InstallGetAddresses(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseInstallGetAddressesResp(rsp) +} + +// LoginWithBodyWithResponse request with arbitrary body returning *LoginResp +func (c *ClientWithResponses) LoginWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LoginResp, error) { + rsp, err := c.LoginWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLoginResp(rsp) +} + +func (c *ClientWithResponses) LoginWithResponse(ctx context.Context, body LoginJSONRequestBody, reqEditors ...RequestEditorFn) (*LoginResp, error) { + rsp, err := c.Login(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLoginResp(rsp) +} + +// LogoutWithResponse request returning *LogoutResp +func (c *ClientWithResponses) LogoutWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*LogoutResp, error) { + rsp, err := c.Logout(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseLogoutResp(rsp) +} + +// ParentalDisableWithResponse request returning *ParentalDisableResp +func (c *ClientWithResponses) ParentalDisableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ParentalDisableResp, error) { + rsp, err := c.ParentalDisable(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseParentalDisableResp(rsp) +} + +// ParentalEnableWithResponse request returning *ParentalEnableResp +func (c *ClientWithResponses) ParentalEnableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ParentalEnableResp, error) { + rsp, err := c.ParentalEnable(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseParentalEnableResp(rsp) +} + +// ParentalStatusWithResponse request returning *ParentalStatusResp +func (c *ClientWithResponses) ParentalStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ParentalStatusResp, error) { + rsp, err := c.ParentalStatus(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseParentalStatusResp(rsp) +} + +// GetProfileWithResponse request returning *GetProfileResp +func (c *ClientWithResponses) GetProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileResp, error) { + rsp, err := c.GetProfile(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetProfileResp(rsp) +} + +// UpdateProfileWithBodyWithResponse request with arbitrary body returning *UpdateProfileResp +func (c *ClientWithResponses) UpdateProfileWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProfileResp, error) { + rsp, err := c.UpdateProfileWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateProfileResp(rsp) +} + +func (c *ClientWithResponses) UpdateProfileWithResponse(ctx context.Context, body UpdateProfileJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProfileResp, error) { + rsp, err := c.UpdateProfile(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateProfileResp(rsp) +} + +// SetProtectionWithBodyWithResponse request with arbitrary body returning *SetProtectionResp +func (c *ClientWithResponses) SetProtectionWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetProtectionResp, error) { + rsp, err := c.SetProtectionWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetProtectionResp(rsp) +} + +func (c *ClientWithResponses) SetProtectionWithResponse(ctx context.Context, body SetProtectionJSONRequestBody, reqEditors ...RequestEditorFn) (*SetProtectionResp, error) { + rsp, err := c.SetProtection(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetProtectionResp(rsp) +} + +// QueryLogWithResponse request returning *QueryLogResp +func (c *ClientWithResponses) QueryLogWithResponse(ctx context.Context, params *QueryLogParams, reqEditors ...RequestEditorFn) (*QueryLogResp, error) { + rsp, err := c.QueryLog(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseQueryLogResp(rsp) +} + +// GetQueryLogConfigWithResponse request returning *GetQueryLogConfigResp +func (c *ClientWithResponses) GetQueryLogConfigWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetQueryLogConfigResp, error) { + rsp, err := c.GetQueryLogConfig(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetQueryLogConfigResp(rsp) +} + +// PutQueryLogConfigWithBodyWithResponse request with arbitrary body returning *PutQueryLogConfigResp +func (c *ClientWithResponses) PutQueryLogConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutQueryLogConfigResp, error) { + rsp, err := c.PutQueryLogConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutQueryLogConfigResp(rsp) +} + +func (c *ClientWithResponses) PutQueryLogConfigWithResponse(ctx context.Context, body PutQueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*PutQueryLogConfigResp, error) { + rsp, err := c.PutQueryLogConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutQueryLogConfigResp(rsp) +} + +// QuerylogClearWithResponse request returning *QuerylogClearResp +func (c *ClientWithResponses) QuerylogClearWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*QuerylogClearResp, error) { + rsp, err := c.QuerylogClear(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseQuerylogClearResp(rsp) +} + +// QueryLogConfigWithBodyWithResponse request with arbitrary body returning *QueryLogConfigResp +func (c *ClientWithResponses) QueryLogConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*QueryLogConfigResp, error) { + rsp, err := c.QueryLogConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseQueryLogConfigResp(rsp) +} + +func (c *ClientWithResponses) QueryLogConfigWithResponse(ctx context.Context, body QueryLogConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*QueryLogConfigResp, error) { + rsp, err := c.QueryLogConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseQueryLogConfigResp(rsp) +} + +// QueryLogInfoWithResponse request returning *QueryLogInfoResp +func (c *ClientWithResponses) QueryLogInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*QueryLogInfoResp, error) { + rsp, err := c.QueryLogInfo(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseQueryLogInfoResp(rsp) +} + +// RewriteAddWithBodyWithResponse request with arbitrary body returning *RewriteAddResp +func (c *ClientWithResponses) RewriteAddWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewriteAddResp, error) { + rsp, err := c.RewriteAddWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewriteAddResp(rsp) +} + +func (c *ClientWithResponses) RewriteAddWithResponse(ctx context.Context, body RewriteAddJSONRequestBody, reqEditors ...RequestEditorFn) (*RewriteAddResp, error) { + rsp, err := c.RewriteAdd(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewriteAddResp(rsp) +} + +// RewriteDeleteWithBodyWithResponse request with arbitrary body returning *RewriteDeleteResp +func (c *ClientWithResponses) RewriteDeleteWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewriteDeleteResp, error) { + rsp, err := c.RewriteDeleteWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewriteDeleteResp(rsp) +} + +func (c *ClientWithResponses) RewriteDeleteWithResponse(ctx context.Context, body RewriteDeleteJSONRequestBody, reqEditors ...RequestEditorFn) (*RewriteDeleteResp, error) { + rsp, err := c.RewriteDelete(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewriteDeleteResp(rsp) +} + +// RewriteListWithResponse request returning *RewriteListResp +func (c *ClientWithResponses) RewriteListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*RewriteListResp, error) { + rsp, err := c.RewriteList(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewriteListResp(rsp) +} + +// RewriteUpdateWithBodyWithResponse request with arbitrary body returning *RewriteUpdateResp +func (c *ClientWithResponses) RewriteUpdateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RewriteUpdateResp, error) { + rsp, err := c.RewriteUpdateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewriteUpdateResp(rsp) +} + +func (c *ClientWithResponses) RewriteUpdateWithResponse(ctx context.Context, body RewriteUpdateJSONRequestBody, reqEditors ...RequestEditorFn) (*RewriteUpdateResp, error) { + rsp, err := c.RewriteUpdate(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRewriteUpdateResp(rsp) +} + +// SafebrowsingDisableWithResponse request returning *SafebrowsingDisableResp +func (c *ClientWithResponses) SafebrowsingDisableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafebrowsingDisableResp, error) { + rsp, err := c.SafebrowsingDisable(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafebrowsingDisableResp(rsp) +} + +// SafebrowsingEnableWithResponse request returning *SafebrowsingEnableResp +func (c *ClientWithResponses) SafebrowsingEnableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafebrowsingEnableResp, error) { + rsp, err := c.SafebrowsingEnable(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafebrowsingEnableResp(rsp) +} + +// SafebrowsingStatusWithResponse request returning *SafebrowsingStatusResp +func (c *ClientWithResponses) SafebrowsingStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafebrowsingStatusResp, error) { + rsp, err := c.SafebrowsingStatus(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafebrowsingStatusResp(rsp) +} + +// SafesearchDisableWithResponse request returning *SafesearchDisableResp +func (c *ClientWithResponses) SafesearchDisableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafesearchDisableResp, error) { + rsp, err := c.SafesearchDisable(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafesearchDisableResp(rsp) +} + +// SafesearchEnableWithResponse request returning *SafesearchEnableResp +func (c *ClientWithResponses) SafesearchEnableWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafesearchEnableResp, error) { + rsp, err := c.SafesearchEnable(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafesearchEnableResp(rsp) +} + +// SafesearchSettingsWithBodyWithResponse request with arbitrary body returning *SafesearchSettingsResp +func (c *ClientWithResponses) SafesearchSettingsWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SafesearchSettingsResp, error) { + rsp, err := c.SafesearchSettingsWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafesearchSettingsResp(rsp) +} + +func (c *ClientWithResponses) SafesearchSettingsWithResponse(ctx context.Context, body SafesearchSettingsJSONRequestBody, reqEditors ...RequestEditorFn) (*SafesearchSettingsResp, error) { + rsp, err := c.SafesearchSettings(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafesearchSettingsResp(rsp) +} + +// SafesearchStatusWithResponse request returning *SafesearchStatusResp +func (c *ClientWithResponses) SafesearchStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*SafesearchStatusResp, error) { + rsp, err := c.SafesearchStatus(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseSafesearchStatusResp(rsp) +} + +// StatsWithResponse request returning *StatsResp +func (c *ClientWithResponses) StatsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatsResp, error) { + rsp, err := c.Stats(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseStatsResp(rsp) +} + +// GetStatsConfigWithResponse request returning *GetStatsConfigResp +func (c *ClientWithResponses) GetStatsConfigWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetStatsConfigResp, error) { + rsp, err := c.GetStatsConfig(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetStatsConfigResp(rsp) +} + +// PutStatsConfigWithBodyWithResponse request with arbitrary body returning *PutStatsConfigResp +func (c *ClientWithResponses) PutStatsConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PutStatsConfigResp, error) { + rsp, err := c.PutStatsConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutStatsConfigResp(rsp) +} + +func (c *ClientWithResponses) PutStatsConfigWithResponse(ctx context.Context, body PutStatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*PutStatsConfigResp, error) { + rsp, err := c.PutStatsConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePutStatsConfigResp(rsp) +} + +// StatsConfigWithBodyWithResponse request with arbitrary body returning *StatsConfigResp +func (c *ClientWithResponses) StatsConfigWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*StatsConfigResp, error) { + rsp, err := c.StatsConfigWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseStatsConfigResp(rsp) +} + +func (c *ClientWithResponses) StatsConfigWithResponse(ctx context.Context, body StatsConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*StatsConfigResp, error) { + rsp, err := c.StatsConfig(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseStatsConfigResp(rsp) +} + +// StatsInfoWithResponse request returning *StatsInfoResp +func (c *ClientWithResponses) StatsInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatsInfoResp, error) { + rsp, err := c.StatsInfo(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseStatsInfoResp(rsp) +} + +// StatsResetWithResponse request returning *StatsResetResp +func (c *ClientWithResponses) StatsResetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatsResetResp, error) { + rsp, err := c.StatsReset(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseStatsResetResp(rsp) +} + +// StatusWithResponse request returning *StatusResp +func (c *ClientWithResponses) StatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*StatusResp, error) { + rsp, err := c.Status(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseStatusResp(rsp) +} + +// TestUpstreamDNSWithBodyWithResponse request with arbitrary body returning *TestUpstreamDNSResp +func (c *ClientWithResponses) TestUpstreamDNSWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TestUpstreamDNSResp, error) { + rsp, err := c.TestUpstreamDNSWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTestUpstreamDNSResp(rsp) +} + +func (c *ClientWithResponses) TestUpstreamDNSWithResponse(ctx context.Context, body TestUpstreamDNSJSONRequestBody, reqEditors ...RequestEditorFn) (*TestUpstreamDNSResp, error) { + rsp, err := c.TestUpstreamDNS(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTestUpstreamDNSResp(rsp) +} + +// TlsConfigureWithBodyWithResponse request with arbitrary body returning *TlsConfigureResp +func (c *ClientWithResponses) TlsConfigureWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TlsConfigureResp, error) { + rsp, err := c.TlsConfigureWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTlsConfigureResp(rsp) +} + +func (c *ClientWithResponses) TlsConfigureWithResponse(ctx context.Context, body TlsConfigureJSONRequestBody, reqEditors ...RequestEditorFn) (*TlsConfigureResp, error) { + rsp, err := c.TlsConfigure(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTlsConfigureResp(rsp) +} + +// TlsStatusWithResponse request returning *TlsStatusResp +func (c *ClientWithResponses) TlsStatusWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*TlsStatusResp, error) { + rsp, err := c.TlsStatus(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseTlsStatusResp(rsp) +} + +// TlsValidateWithBodyWithResponse request with arbitrary body returning *TlsValidateResp +func (c *ClientWithResponses) TlsValidateWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TlsValidateResp, error) { + rsp, err := c.TlsValidateWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTlsValidateResp(rsp) +} + +func (c *ClientWithResponses) TlsValidateWithResponse(ctx context.Context, body TlsValidateJSONRequestBody, reqEditors ...RequestEditorFn) (*TlsValidateResp, error) { + rsp, err := c.TlsValidate(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseTlsValidateResp(rsp) +} + +// BeginUpdateWithResponse request returning *BeginUpdateResp +func (c *ClientWithResponses) BeginUpdateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*BeginUpdateResp, error) { + rsp, err := c.BeginUpdate(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseBeginUpdateResp(rsp) +} + +// GetVersionJsonWithBodyWithResponse request with arbitrary body returning *GetVersionJsonResp +func (c *ClientWithResponses) GetVersionJsonWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*GetVersionJsonResp, error) { + rsp, err := c.GetVersionJsonWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVersionJsonResp(rsp) +} + +func (c *ClientWithResponses) GetVersionJsonWithResponse(ctx context.Context, body GetVersionJsonJSONRequestBody, reqEditors ...RequestEditorFn) (*GetVersionJsonResp, error) { + rsp, err := c.GetVersionJson(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetVersionJsonResp(rsp) +} + +// ParseAccessListResp parses an HTTP response from a AccessListWithResponse call +func ParseAccessListResp(rsp *http.Response) (*AccessListResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AccessListResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AccessListResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseAccessSetResp parses an HTTP response from a AccessSetWithResponse call +func ParseAccessSetResp(rsp *http.Response) (*AccessSetResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AccessSetResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseMobileConfigDoHResp parses an HTTP response from a MobileConfigDoHWithResponse call +func ParseMobileConfigDoHResp(rsp *http.Response) (*MobileConfigDoHResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &MobileConfigDoHResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseMobileConfigDoTResp parses an HTTP response from a MobileConfigDoTWithResponse call +func ParseMobileConfigDoTResp(rsp *http.Response) (*MobileConfigDoTResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &MobileConfigDoTResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseBlockedServicesAllResp parses an HTTP response from a BlockedServicesAllWithResponse call +func ParseBlockedServicesAllResp(rsp *http.Response) (*BlockedServicesAllResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BlockedServicesAllResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest BlockedServicesAll + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseBlockedServicesScheduleResp parses an HTTP response from a BlockedServicesScheduleWithResponse call +func ParseBlockedServicesScheduleResp(rsp *http.Response) (*BlockedServicesScheduleResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BlockedServicesScheduleResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest BlockedServicesSchedule + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseBlockedServicesListResp parses an HTTP response from a BlockedServicesListWithResponse call +func ParseBlockedServicesListResp(rsp *http.Response) (*BlockedServicesListResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BlockedServicesListResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest BlockedServicesArray + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseBlockedServicesAvailableServicesResp parses an HTTP response from a BlockedServicesAvailableServicesWithResponse call +func ParseBlockedServicesAvailableServicesResp(rsp *http.Response) (*BlockedServicesAvailableServicesResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BlockedServicesAvailableServicesResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest BlockedServicesArray + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseBlockedServicesSetResp parses an HTTP response from a BlockedServicesSetWithResponse call +func ParseBlockedServicesSetResp(rsp *http.Response) (*BlockedServicesSetResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BlockedServicesSetResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseBlockedServicesScheduleUpdateResp parses an HTTP response from a BlockedServicesScheduleUpdateWithResponse call +func ParseBlockedServicesScheduleUpdateResp(rsp *http.Response) (*BlockedServicesScheduleUpdateResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BlockedServicesScheduleUpdateResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseCacheClearResp parses an HTTP response from a CacheClearWithResponse call +func ParseCacheClearResp(rsp *http.Response) (*CacheClearResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CacheClearResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseClientsStatusResp parses an HTTP response from a ClientsStatusWithResponse call +func ParseClientsStatusResp(rsp *http.Response) (*ClientsStatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ClientsStatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Clients + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseClientsAddResp parses an HTTP response from a ClientsAddWithResponse call +func ParseClientsAddResp(rsp *http.Response) (*ClientsAddResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ClientsAddResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseClientsDeleteResp parses an HTTP response from a ClientsDeleteWithResponse call +func ParseClientsDeleteResp(rsp *http.Response) (*ClientsDeleteResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ClientsDeleteResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseClientsFindResp parses an HTTP response from a ClientsFindWithResponse call +func ParseClientsFindResp(rsp *http.Response) (*ClientsFindResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ClientsFindResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ClientsFindResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseClientsUpdateResp parses an HTTP response from a ClientsUpdateWithResponse call +func ParseClientsUpdateResp(rsp *http.Response) (*ClientsUpdateResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ClientsUpdateResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseDhcpAddStaticLeaseResp parses an HTTP response from a DhcpAddStaticLeaseWithResponse call +func ParseDhcpAddStaticLeaseResp(rsp *http.Response) (*DhcpAddStaticLeaseResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpAddStaticLeaseResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + } + + return response, nil +} + +// ParseCheckActiveDhcpResp parses an HTTP response from a CheckActiveDhcpWithResponse call +func ParseCheckActiveDhcpResp(rsp *http.Response) (*CheckActiveDhcpResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CheckActiveDhcpResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DhcpSearchResult + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + } + + return response, nil +} + +// ParseDhcpInterfacesResp parses an HTTP response from a DhcpInterfacesWithResponse call +func ParseDhcpInterfacesResp(rsp *http.Response) (*DhcpInterfacesResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpInterfacesResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest NetInterfaces + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDhcpRemoveStaticLeaseResp parses an HTTP response from a DhcpRemoveStaticLeaseWithResponse call +func ParseDhcpRemoveStaticLeaseResp(rsp *http.Response) (*DhcpRemoveStaticLeaseResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpRemoveStaticLeaseResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + } + + return response, nil +} + +// ParseDhcpResetResp parses an HTTP response from a DhcpResetWithResponse call +func ParseDhcpResetResp(rsp *http.Response) (*DhcpResetResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpResetResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + } + + return response, nil +} + +// ParseDhcpResetLeasesResp parses an HTTP response from a DhcpResetLeasesWithResponse call +func ParseDhcpResetLeasesResp(rsp *http.Response) (*DhcpResetLeasesResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpResetLeasesResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + } + + return response, nil +} + +// ParseDhcpSetConfigResp parses an HTTP response from a DhcpSetConfigWithResponse call +func ParseDhcpSetConfigResp(rsp *http.Response) (*DhcpSetConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpSetConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + } + + return response, nil +} + +// ParseDhcpStatusResp parses an HTTP response from a DhcpStatusWithResponse call +func ParseDhcpStatusResp(rsp *http.Response) (*DhcpStatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpStatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DhcpStatus + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 500: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON500 = &dest + + } + + return response, nil +} + +// ParseDhcpUpdateStaticLeaseResp parses an HTTP response from a DhcpUpdateStaticLeaseWithResponse call +func ParseDhcpUpdateStaticLeaseResp(rsp *http.Response) (*DhcpUpdateStaticLeaseResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DhcpUpdateStaticLeaseResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 501: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON501 = &dest + + } + + return response, nil +} + +// ParseDnsConfigResp parses an HTTP response from a DnsConfigWithResponse call +func ParseDnsConfigResp(rsp *http.Response) (*DnsConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DnsConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseDnsInfoResp parses an HTTP response from a DnsInfoWithResponse call +func ParseDnsInfoResp(rsp *http.Response) (*DnsInfoResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DnsInfoResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DNSConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseFilteringAddURLResp parses an HTTP response from a FilteringAddURLWithResponse call +func ParseFilteringAddURLResp(rsp *http.Response) (*FilteringAddURLResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringAddURLResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseFilteringCheckHostResp parses an HTTP response from a FilteringCheckHostWithResponse call +func ParseFilteringCheckHostResp(rsp *http.Response) (*FilteringCheckHostResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringCheckHostResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FilterCheckHostResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseFilteringConfigResp parses an HTTP response from a FilteringConfigWithResponse call +func ParseFilteringConfigResp(rsp *http.Response) (*FilteringConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseFilteringRefreshResp parses an HTTP response from a FilteringRefreshWithResponse call +func ParseFilteringRefreshResp(rsp *http.Response) (*FilteringRefreshResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringRefreshResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FilterRefreshResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseFilteringRemoveURLResp parses an HTTP response from a FilteringRemoveURLWithResponse call +func ParseFilteringRemoveURLResp(rsp *http.Response) (*FilteringRemoveURLResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringRemoveURLResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseFilteringSetRulesResp parses an HTTP response from a FilteringSetRulesWithResponse call +func ParseFilteringSetRulesResp(rsp *http.Response) (*FilteringSetRulesResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringSetRulesResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseFilteringSetURLResp parses an HTTP response from a FilteringSetURLWithResponse call +func ParseFilteringSetURLResp(rsp *http.Response) (*FilteringSetURLResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringSetURLResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseFilteringStatusResp parses an HTTP response from a FilteringStatusWithResponse call +func ParseFilteringStatusResp(rsp *http.Response) (*FilteringStatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FilteringStatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest FilterStatus + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseChangeLanguageResp parses an HTTP response from a ChangeLanguageWithResponse call +func ParseChangeLanguageResp(rsp *http.Response) (*ChangeLanguageResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ChangeLanguageResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseCurrentLanguageResp parses an HTTP response from a CurrentLanguageWithResponse call +func ParseCurrentLanguageResp(rsp *http.Response) (*CurrentLanguageResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CurrentLanguageResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LanguageSettings + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseInstallCheckConfigResp parses an HTTP response from a InstallCheckConfigWithResponse call +func ParseInstallCheckConfigResp(rsp *http.Response) (*InstallCheckConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &InstallCheckConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest CheckConfigResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseInstallConfigureResp parses an HTTP response from a InstallConfigureWithResponse call +func ParseInstallConfigureResp(rsp *http.Response) (*InstallConfigureResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &InstallConfigureResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseInstallGetAddressesResp parses an HTTP response from a InstallGetAddressesWithResponse call +func ParseInstallGetAddressesResp(rsp *http.Response) (*InstallGetAddressesResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &InstallGetAddressesResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AddressesInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseLoginResp parses an HTTP response from a LoginWithResponse call +func ParseLoginResp(rsp *http.Response) (*LoginResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LoginResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseLogoutResp parses an HTTP response from a LogoutWithResponse call +func ParseLogoutResp(rsp *http.Response) (*LogoutResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LogoutResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseParentalDisableResp parses an HTTP response from a ParentalDisableWithResponse call +func ParseParentalDisableResp(rsp *http.Response) (*ParentalDisableResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ParentalDisableResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseParentalEnableResp parses an HTTP response from a ParentalEnableWithResponse call +func ParseParentalEnableResp(rsp *http.Response) (*ParentalEnableResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ParentalEnableResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseParentalStatusResp parses an HTTP response from a ParentalStatusWithResponse call +func ParseParentalStatusResp(rsp *http.Response) (*ParentalStatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ParentalStatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Enable *bool `json:"enable,omitempty"` + Sensitivity *int `json:"sensitivity,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetProfileResp parses an HTTP response from a GetProfileWithResponse call +func ParseGetProfileResp(rsp *http.Response) (*GetProfileResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetProfileResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProfileInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseUpdateProfileResp parses an HTTP response from a UpdateProfileWithResponse call +func ParseUpdateProfileResp(rsp *http.Response) (*UpdateProfileResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateProfileResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseSetProtectionResp parses an HTTP response from a SetProtectionWithResponse call +func ParseSetProtectionResp(rsp *http.Response) (*SetProtectionResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SetProtectionResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseQueryLogResp parses an HTTP response from a QueryLogWithResponse call +func ParseQueryLogResp(rsp *http.Response) (*QueryLogResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &QueryLogResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest QueryLog + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetQueryLogConfigResp parses an HTTP response from a GetQueryLogConfigWithResponse call +func ParseGetQueryLogConfigResp(rsp *http.Response) (*GetQueryLogConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetQueryLogConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest GetQueryLogConfigResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutQueryLogConfigResp parses an HTTP response from a PutQueryLogConfigWithResponse call +func ParsePutQueryLogConfigResp(rsp *http.Response) (*PutQueryLogConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutQueryLogConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseQuerylogClearResp parses an HTTP response from a QuerylogClearWithResponse call +func ParseQuerylogClearResp(rsp *http.Response) (*QuerylogClearResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &QuerylogClearResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseQueryLogConfigResp parses an HTTP response from a QueryLogConfigWithResponse call +func ParseQueryLogConfigResp(rsp *http.Response) (*QueryLogConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &QueryLogConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseQueryLogInfoResp parses an HTTP response from a QueryLogInfoWithResponse call +func ParseQueryLogInfoResp(rsp *http.Response) (*QueryLogInfoResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &QueryLogInfoResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest QueryLogConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseRewriteAddResp parses an HTTP response from a RewriteAddWithResponse call +func ParseRewriteAddResp(rsp *http.Response) (*RewriteAddResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RewriteAddResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseRewriteDeleteResp parses an HTTP response from a RewriteDeleteWithResponse call +func ParseRewriteDeleteResp(rsp *http.Response) (*RewriteDeleteResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RewriteDeleteResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseRewriteListResp parses an HTTP response from a RewriteListWithResponse call +func ParseRewriteListResp(rsp *http.Response) (*RewriteListResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RewriteListResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RewriteList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseRewriteUpdateResp parses an HTTP response from a RewriteUpdateWithResponse call +func ParseRewriteUpdateResp(rsp *http.Response) (*RewriteUpdateResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RewriteUpdateResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseSafebrowsingDisableResp parses an HTTP response from a SafebrowsingDisableWithResponse call +func ParseSafebrowsingDisableResp(rsp *http.Response) (*SafebrowsingDisableResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SafebrowsingDisableResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseSafebrowsingEnableResp parses an HTTP response from a SafebrowsingEnableWithResponse call +func ParseSafebrowsingEnableResp(rsp *http.Response) (*SafebrowsingEnableResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SafebrowsingEnableResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseSafebrowsingStatusResp parses an HTTP response from a SafebrowsingStatusWithResponse call +func ParseSafebrowsingStatusResp(rsp *http.Response) (*SafebrowsingStatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SafebrowsingStatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Enabled *bool `json:"enabled,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseSafesearchDisableResp parses an HTTP response from a SafesearchDisableWithResponse call +func ParseSafesearchDisableResp(rsp *http.Response) (*SafesearchDisableResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SafesearchDisableResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseSafesearchEnableResp parses an HTTP response from a SafesearchEnableWithResponse call +func ParseSafesearchEnableResp(rsp *http.Response) (*SafesearchEnableResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SafesearchEnableResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseSafesearchSettingsResp parses an HTTP response from a SafesearchSettingsWithResponse call +func ParseSafesearchSettingsResp(rsp *http.Response) (*SafesearchSettingsResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SafesearchSettingsResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseSafesearchStatusResp parses an HTTP response from a SafesearchStatusWithResponse call +func ParseSafesearchStatusResp(rsp *http.Response) (*SafesearchStatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &SafesearchStatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SafeSearchConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseStatsResp parses an HTTP response from a StatsWithResponse call +func ParseStatsResp(rsp *http.Response) (*StatsResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StatsResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Stats + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseGetStatsConfigResp parses an HTTP response from a GetStatsConfigWithResponse call +func ParseGetStatsConfigResp(rsp *http.Response) (*GetStatsConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetStatsConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest GetStatsConfigResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParsePutStatsConfigResp parses an HTTP response from a PutStatsConfigWithResponse call +func ParsePutStatsConfigResp(rsp *http.Response) (*PutStatsConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PutStatsConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseStatsConfigResp parses an HTTP response from a StatsConfigWithResponse call +func ParseStatsConfigResp(rsp *http.Response) (*StatsConfigResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StatsConfigResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseStatsInfoResp parses an HTTP response from a StatsInfoWithResponse call +func ParseStatsInfoResp(rsp *http.Response) (*StatsInfoResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StatsInfoResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest StatsConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseStatsResetResp parses an HTTP response from a StatsResetWithResponse call +func ParseStatsResetResp(rsp *http.Response) (*StatsResetResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StatsResetResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseStatusResp parses an HTTP response from a StatusWithResponse call +func ParseStatusResp(rsp *http.Response) (*StatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &StatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ServerStatus + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseTestUpstreamDNSResp parses an HTTP response from a TestUpstreamDNSWithResponse call +func ParseTestUpstreamDNSResp(rsp *http.Response) (*TestUpstreamDNSResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TestUpstreamDNSResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UpstreamsConfigResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseTlsConfigureResp parses an HTTP response from a TlsConfigureWithResponse call +func ParseTlsConfigureResp(rsp *http.Response) (*TlsConfigureResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TlsConfigureResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest TlsConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseTlsStatusResp parses an HTTP response from a TlsStatusWithResponse call +func ParseTlsStatusResp(rsp *http.Response) (*TlsStatusResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TlsStatusResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest TlsConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseTlsValidateResp parses an HTTP response from a TlsValidateWithResponse call +func ParseTlsValidateResp(rsp *http.Response) (*TlsValidateResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &TlsValidateResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest TlsConfig + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseBeginUpdateResp parses an HTTP response from a BeginUpdateWithResponse call +func ParseBeginUpdateResp(rsp *http.Response) (*BeginUpdateResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &BeginUpdateResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseGetVersionJsonResp parses an HTTP response from a GetVersionJsonWithResponse call +func ParseGetVersionJsonResp(rsp *http.Response) (*GetVersionJsonResp, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetVersionJsonResp{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest VersionInfo + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} diff --git a/pkg/types/types_suite_test.go b/pkg/client/model/model_suite_test.go similarity index 75% rename from pkg/types/types_suite_test.go rename to pkg/client/model/model_suite_test.go index 3356638..68c7648 100644 --- a/pkg/types/types_suite_test.go +++ b/pkg/client/model/model_suite_test.go @@ -1,4 +1,4 @@ -package types_test +package model_test import ( "testing" @@ -9,5 +9,5 @@ import ( func TestTypes(t *testing.T) { RegisterFailHandler(Fail) - RunSpecs(t, "Types Suite") + RunSpecs(t, "Model Suite") } diff --git a/pkg/types/types_test.go b/pkg/client/model/model_test.go similarity index 51% rename from pkg/types/types_test.go rename to pkg/client/model/model_test.go index 8ecdb8a..06a34f2 100644 --- a/pkg/types/types_test.go +++ b/pkg/client/model/model_test.go @@ -1,12 +1,12 @@ -package types_test +package model_test import ( "encoding/json" - "net" "os" + "github.com/bakito/adguardhome-sync/pkg/client/model" "github.com/bakito/adguardhome-sync/pkg/types" - "github.com/bakito/adguardhome-sync/pkg/versions" + "github.com/bakito/adguardhome-sync/pkg/utils" "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -24,8 +24,8 @@ var _ = Describe("Types", func() { Context("FilteringStatus", func() { It("should correctly parse json", func() { - b, err := os.ReadFile("../..//testdata/filtering-status.json") - fs := &types.FilteringStatus{} + b, err := os.ReadFile("../../../testdata/filtering-status.json") + fs := &model.FilterStatus{} Ω(err).ShouldNot(HaveOccurred()) err = json.Unmarshal(b, fs) Ω(err).ShouldNot(HaveOccurred()) @@ -35,39 +35,39 @@ var _ = Describe("Types", func() { Context("Filters", func() { Context("Merge", func() { var ( - originFilters types.Filters - replicaFilters types.Filters + originFilters []model.Filter + replicaFilters []model.Filter ) BeforeEach(func() { - originFilters = types.Filters{} - replicaFilters = types.Filters{} + originFilters = []model.Filter{} + replicaFilters = []model.Filter{} }) It("should add a missing filter", func() { - originFilters = append(originFilters, types.Filter{URL: url}) - a, u, d := replicaFilters.Merge(originFilters) + originFilters = append(originFilters, model.Filter{Url: url}) + a, u, d := model.MergeFilters(&replicaFilters, &originFilters) Ω(a).Should(HaveLen(1)) Ω(u).Should(BeEmpty()) Ω(d).Should(BeEmpty()) - Ω(a[0].URL).Should(Equal(url)) + Ω(a[0].Url).Should(Equal(url)) }) It("should remove additional filter", func() { - replicaFilters = append(replicaFilters, types.Filter{URL: url}) - a, u, d := replicaFilters.Merge(originFilters) + replicaFilters = append(replicaFilters, model.Filter{Url: url}) + a, u, d := model.MergeFilters(&replicaFilters, &originFilters) Ω(a).Should(BeEmpty()) Ω(u).Should(BeEmpty()) Ω(d).Should(HaveLen(1)) - Ω(d[0].URL).Should(Equal(url)) + Ω(d[0].Url).Should(Equal(url)) }) It("should update existing filter when enabled differs", func() { enabled := true - originFilters = append(originFilters, types.Filter{URL: url, Enabled: enabled}) - replicaFilters = append(replicaFilters, types.Filter{URL: url, Enabled: !enabled}) - a, u, d := replicaFilters.Merge(originFilters) + originFilters = append(originFilters, model.Filter{Url: url, Enabled: enabled}) + replicaFilters = append(replicaFilters, model.Filter{Url: url, Enabled: !enabled}) + a, u, d := model.MergeFilters(&replicaFilters, &originFilters) Ω(a).Should(BeEmpty()) Ω(u).Should(HaveLen(1)) Ω(d).Should(BeEmpty()) @@ -78,9 +78,9 @@ var _ = Describe("Types", func() { It("should update existing filter when name differs", func() { name1 := uuid.NewString() name2 := uuid.NewString() - originFilters = append(originFilters, types.Filter{URL: url, Name: name1}) - replicaFilters = append(replicaFilters, types.Filter{URL: url, Name: name2}) - a, u, d := replicaFilters.Merge(originFilters) + originFilters = append(originFilters, model.Filter{Url: url, Name: name1}) + replicaFilters = append(replicaFilters, model.Filter{Url: url, Name: name2}) + a, u, d := model.MergeFilters(&replicaFilters, &originFilters) Ω(a).Should(BeEmpty()) Ω(u).Should(HaveLen(1)) Ω(d).Should(BeEmpty()) @@ -89,9 +89,9 @@ var _ = Describe("Types", func() { }) It("should have no changes", func() { - originFilters = append(originFilters, types.Filter{URL: url}) - replicaFilters = append(replicaFilters, types.Filter{URL: url}) - a, u, d := replicaFilters.Merge(originFilters) + originFilters = append(originFilters, model.Filter{Url: url}) + replicaFilters = append(replicaFilters, model.Filter{Url: url}) + a, u, d := model.MergeFilters(&replicaFilters, &originFilters) Ω(a).Should(BeEmpty()) Ω(u).Should(BeEmpty()) Ω(d).Should(BeEmpty()) @@ -108,42 +108,45 @@ var _ = Describe("Types", func() { It("should build a key with url and api apiPath", func() { domain := uuid.NewString() answer := uuid.NewString() - re := &types.RewriteEntry{Domain: domain, Answer: answer} + re := &model.RewriteEntry{Domain: utils.Ptr(domain), Answer: utils.Ptr(answer)} Ω(re.Key()).Should(Equal(domain + "#" + answer)) }) }) Context("QueryLogConfig", func() { Context("Equal", func() { var ( - a *types.QueryLogConfig - b *types.QueryLogConfig + a *model.QueryLogConfig + b *model.QueryLogConfig ) BeforeEach(func() { - a = &types.QueryLogConfig{} - b = &types.QueryLogConfig{} + a = &model.QueryLogConfig{} + b = &model.QueryLogConfig{} }) It("should be equal", func() { - a.Enabled = true - a.Interval = 1 - a.AnonymizeClientIP = true - b.Enabled = true - b.Interval = 1 - b.AnonymizeClientIP = true + a.Enabled = utils.Ptr(true) + var interval model.QueryLogConfigInterval = 1 + a.Interval = &interval + a.AnonymizeClientIp = utils.Ptr(true) + b.Enabled = utils.Ptr(true) + b.Interval = &interval + b.AnonymizeClientIp = utils.Ptr(true) Ω(a.Equals(b)).Should(BeTrue()) }) It("should not be equal when enabled differs", func() { - a.Enabled = true - b.Enabled = false + a.Enabled = utils.Ptr(true) + b.Enabled = utils.Ptr(false) Ω(a.Equals(b)).ShouldNot(BeTrue()) }) It("should not be equal when interval differs", func() { - a.Interval = 1 - b.Interval = 2 + var interval1 model.QueryLogConfigInterval = 1 + var interval2 model.QueryLogConfigInterval = 2 + a.Interval = &interval1 + b.Interval = &interval2 Ω(a.Equals(b)).ShouldNot(BeTrue()) }) It("should not be equal when anonymizeClientIP differs", func() { - a.AnonymizeClientIP = true - b.AnonymizeClientIP = false + a.AnonymizeClientIp = utils.Ptr(true) + b.AnonymizeClientIp = utils.Ptr(false) Ω(a.Equals(b)).ShouldNot(BeTrue()) }) }) @@ -151,39 +154,39 @@ var _ = Describe("Types", func() { Context("RewriteEntries", func() { Context("Merge", func() { var ( - originRE types.RewriteEntries - replicaRE types.RewriteEntries + originRE model.RewriteEntries + replicaRE model.RewriteEntries domain string ) BeforeEach(func() { - originRE = types.RewriteEntries{} - replicaRE = types.RewriteEntries{} + originRE = model.RewriteEntries{} + replicaRE = model.RewriteEntries{} domain = uuid.NewString() }) It("should add a missing rewrite entry", func() { - originRE = append(originRE, types.RewriteEntry{Domain: domain}) + originRE = append(originRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) a, r, d := replicaRE.Merge(&originRE) Ω(a).Should(HaveLen(1)) Ω(r).Should(BeEmpty()) Ω(d).Should(BeEmpty()) - Ω(a[0].Domain).Should(Equal(domain)) + Ω(*a[0].Domain).Should(Equal(domain)) }) - It("should remove additional ewrite entry", func() { - replicaRE = append(replicaRE, types.RewriteEntry{Domain: domain}) + It("should remove additional rewrite entry", func() { + replicaRE = append(replicaRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) a, r, d := replicaRE.Merge(&originRE) Ω(a).Should(BeEmpty()) Ω(r).Should(HaveLen(1)) Ω(d).Should(BeEmpty()) - Ω(r[0].Domain).Should(Equal(domain)) + Ω(*r[0].Domain).Should(Equal(domain)) }) It("should have no changes", func() { - originRE = append(originRE, types.RewriteEntry{Domain: domain}) - replicaRE = append(replicaRE, types.RewriteEntry{Domain: domain}) + originRE = append(originRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) + replicaRE = append(replicaRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) a, r, d := replicaRE.Merge(&originRE) Ω(a).Should(BeEmpty()) Ω(r).Should(BeEmpty()) @@ -191,9 +194,9 @@ var _ = Describe("Types", func() { }) It("should remove target duplicate", func() { - originRE = append(originRE, types.RewriteEntry{Domain: domain}) - replicaRE = append(replicaRE, types.RewriteEntry{Domain: domain}) - replicaRE = append(replicaRE, types.RewriteEntry{Domain: domain}) + originRE = append(originRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) + replicaRE = append(replicaRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) + replicaRE = append(replicaRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) a, r, d := replicaRE.Merge(&originRE) Ω(a).Should(BeEmpty()) Ω(r).Should(HaveLen(1)) @@ -201,9 +204,9 @@ var _ = Describe("Types", func() { }) It("should remove target duplicate", func() { - originRE = append(originRE, types.RewriteEntry{Domain: domain}) - originRE = append(originRE, types.RewriteEntry{Domain: domain}) - replicaRE = append(replicaRE, types.RewriteEntry{Domain: domain}) + originRE = append(originRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) + originRE = append(originRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) + replicaRE = append(replicaRE, model.RewriteEntry{Domain: utils.Ptr(domain)}) a, r, d := replicaRE.Merge(&originRE) Ω(a).Should(BeEmpty()) Ω(r).Should(BeEmpty()) @@ -211,34 +214,6 @@ var _ = Describe("Types", func() { }) }) }) - Context("UserRules", func() { - It("should join the rules correctly", func() { - r1 := uuid.NewString() - r2 := uuid.NewString() - ur := types.UserRules([]string{r1, r2}) - Ω(ur.String()).Should(Equal(r1 + "\n" + r2)) - }) - It("should return a string for versions <= "+versions.LastStringCustomRules, func() { - r1 := uuid.NewString() - r2 := uuid.NewString() - pl := types.UserRules([]string{r1, r2}).ToPayload(versions.LastStringCustomRules) - Ω(pl).Should(BeAssignableToTypeOf("")) - }) - It("should return a struct for versions > "+versions.IncompatibleAPI, func() { - r1 := uuid.NewString() - r2 := uuid.NewString() - pl := types.UserRules([]string{r1, r2}).ToPayload(versions.FixedIncompatibleAPI) - Ω(pl).Should(BeAssignableToTypeOf(&types.UserRulesRequest{})) - }) - }) - Context("UserRulesRequest", func() { - It("should join the rules correctly", func() { - r1 := uuid.NewString() - r2 := uuid.NewString() - urr := types.UserRulesRequest{Rules: []string{r1, r2}} - Ω(urr.String()).Should(Equal(r1 + "\n" + r2)) - }) - }) Context("Config", func() { var cfg *types.Config BeforeEach(func() { @@ -285,78 +260,78 @@ var _ = Describe("Types", func() { Context("Clients", func() { Context("Merge", func() { var ( - originClients *types.Clients - replicaClients types.Clients + originClients *model.Clients + replicaClients model.Clients name string ) BeforeEach(func() { - originClients = &types.Clients{} - replicaClients = types.Clients{} + originClients = &model.Clients{} + replicaClients = model.Clients{} name = uuid.NewString() }) It("should add a missing client", func() { - originClients.Clients = append(originClients.Clients, types.Client{Name: name}) + originClients.Add(model.Client{Name: utils.Ptr(name)}) a, u, d := replicaClients.Merge(originClients) Ω(a).Should(HaveLen(1)) Ω(u).Should(BeEmpty()) Ω(d).Should(BeEmpty()) - Ω(a[0].Name).Should(Equal(name)) + Ω(*a[0].Name).Should(Equal(name)) }) It("should remove additional client", func() { - replicaClients.Clients = append(replicaClients.Clients, types.Client{Name: name}) + replicaClients.Add(model.Client{Name: utils.Ptr(name)}) a, u, d := replicaClients.Merge(originClients) Ω(a).Should(BeEmpty()) Ω(u).Should(BeEmpty()) Ω(d).Should(HaveLen(1)) - Ω(d[0].Name).Should(Equal(name)) + Ω(*d[0].Name).Should(Equal(name)) }) It("should update existing client when name differs", func() { disallowed := true - originClients.Clients = append(originClients.Clients, types.Client{Name: name, Disallowed: disallowed}) - replicaClients.Clients = append(replicaClients.Clients, types.Client{Name: name, Disallowed: !disallowed}) + originClients.Add(model.Client{Name: utils.Ptr(name), FilteringEnabled: utils.Ptr(disallowed)}) + replicaClients.Add(model.Client{Name: utils.Ptr(name), FilteringEnabled: utils.Ptr(!disallowed)}) a, u, d := replicaClients.Merge(originClients) Ω(a).Should(BeEmpty()) Ω(u).Should(HaveLen(1)) Ω(d).Should(BeEmpty()) - Ω(u[0].Disallowed).Should(Equal(disallowed)) + Ω(*u[0].FilteringEnabled).Should(Equal(disallowed)) }) }) }) - Context("Services", func() { + Context("BlockedServices", func() { Context("Equals", func() { It("should be equal", func() { - s1 := types.Services([]string{"a", "b"}) - s2 := types.Services([]string{"b", "a"}) - Ω(s1.Equals(s2)).Should(BeTrue()) + s1 := &model.BlockedServicesArray{"a", "b"} + s2 := &model.BlockedServicesArray{"b", "a"} + Ω(model.EqualsStringSlice(s1, s2, true)).Should(BeTrue()) }) It("should not be equal different values", func() { - s1 := types.Services([]string{"a", "b"}) - s2 := types.Services([]string{"B", "a"}) - Ω(s1.Equals(s2)).ShouldNot(BeTrue()) + s1 := &model.BlockedServicesArray{"a", "b"} + s2 := &model.BlockedServicesArray{"B", "a"} + Ω(model.EqualsStringSlice(s1, s2, true)).ShouldNot(BeTrue()) }) It("should not be equal different length", func() { - s1 := types.Services([]string{"a", "b"}) - s2 := types.Services([]string{"b", "a", "c"}) - Ω(s1.Equals(s2)).ShouldNot(BeTrue()) + s1 := &model.BlockedServicesArray{"a", "b"} + s2 := &model.BlockedServicesArray{"b", "a", "c"} + Ω(model.EqualsStringSlice(s1, s2, true)).ShouldNot(BeTrue()) }) }) }) Context("DNSConfig", func() { Context("Equals", func() { It("should be equal", func() { - dc1 := &types.DNSConfig{Upstreams: []string{"a"}} - dc2 := &types.DNSConfig{Upstreams: []string{"a"}} + dc1 := &model.DNSConfig{LocalPtrUpstreams: utils.Ptr([]string{"a"})} + dc2 := &model.DNSConfig{LocalPtrUpstreams: utils.Ptr([]string{"a"})} Ω(dc1.Equals(dc2)).Should(BeTrue()) }) It("should not be equal", func() { - dc1 := &types.DNSConfig{Upstreams: []string{"a"}} - dc2 := &types.DNSConfig{Upstreams: []string{"b"}} + dc1 := &model.DNSConfig{LocalPtrUpstreams: utils.Ptr([]string{"a"})} + dc2 := &model.DNSConfig{LocalPtrUpstreams: utils.Ptr([]string{"b"})} Ω(dc1.Equals(dc2)).ShouldNot(BeTrue()) }) }) @@ -364,43 +339,43 @@ var _ = Describe("Types", func() { Context("DHCPServerConfig", func() { Context("Equals", func() { It("should be equal", func() { - dc1 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{ - GatewayIP: net.IPv4(1, 2, 3, 4), - LeaseDuration: 123, - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), - SubnetMask: net.IPv4(255, 255, 255, 0), + dc1 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{ + GatewayIp: utils.Ptr("1.2.3.4"), + LeaseDuration: utils.Ptr(123), + RangeStart: utils.Ptr("1.2.3.5"), + RangeEnd: utils.Ptr("1.2.3.6"), + SubnetMask: utils.Ptr("255.255.255.0"), }, } - dc2 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{ - GatewayIP: net.IPv4(1, 2, 3, 4), - LeaseDuration: 123, - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), - SubnetMask: net.IPv4(255, 255, 255, 0), + dc2 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{ + GatewayIp: utils.Ptr("1.2.3.4"), + LeaseDuration: utils.Ptr(123), + RangeStart: utils.Ptr("1.2.3.5"), + RangeEnd: utils.Ptr("1.2.3.6"), + SubnetMask: utils.Ptr("255.255.255.0"), }, } Ω(dc1.Equals(dc2)).Should(BeTrue()) }) It("should not be equal", func() { - dc1 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{ - GatewayIP: net.IPv4(1, 2, 3, 3), - LeaseDuration: 123, - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), - SubnetMask: net.IPv4(255, 255, 255, 0), + dc1 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{ + GatewayIp: utils.Ptr("1.2.3.3"), + LeaseDuration: utils.Ptr(123), + RangeStart: utils.Ptr("1.2.3.5"), + RangeEnd: utils.Ptr("1.2.3.6"), + SubnetMask: utils.Ptr("255.255.255.0"), }, } - dc2 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{ - GatewayIP: net.IPv4(1, 2, 3, 4), - LeaseDuration: 123, - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), - SubnetMask: net.IPv4(255, 255, 255, 0), + dc2 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{ + GatewayIp: utils.Ptr("1.2.3.4"), + LeaseDuration: utils.Ptr(123), + RangeStart: utils.Ptr("1.2.3.5"), + RangeEnd: utils.Ptr("1.2.3.6"), + SubnetMask: utils.Ptr("255.255.255.0"), }, } Ω(dc1.Equals(dc2)).ShouldNot(BeTrue()) @@ -408,13 +383,13 @@ var _ = Describe("Types", func() { }) Context("Clone", func() { It("clone should be equal", func() { - dc1 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{ - GatewayIP: net.IPv4(1, 2, 3, 4), - LeaseDuration: 123, - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), - SubnetMask: net.IPv4(255, 255, 255, 0), + dc1 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{ + GatewayIp: utils.Ptr("1.2.3.4"), + LeaseDuration: utils.Ptr(123), + RangeStart: utils.Ptr("1.2.3.5"), + RangeEnd: utils.Ptr("1.2.3.6"), + SubnetMask: utils.Ptr("255.255.255.0"), }, } Ω(dc1.Clone().Equals(dc1)).Should(BeTrue()) @@ -422,30 +397,30 @@ var _ = Describe("Types", func() { }) Context("HasConfig", func() { It("should not have a config", func() { - dc1 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{}, - V6: &types.V6ServerConfJSON{}, + dc1 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{}, + V6: &model.DhcpConfigV6{}, } Ω(dc1.HasConfig()).Should(BeFalse()) }) It("should not have a v4 config", func() { - dc1 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{ - GatewayIP: net.IPv4(1, 2, 3, 4), - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), - SubnetMask: net.IPv4(255, 255, 255, 0), + dc1 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{ + GatewayIp: utils.Ptr("1.2.3.4"), + LeaseDuration: utils.Ptr(123), + RangeStart: utils.Ptr("1.2.3.5"), + RangeEnd: utils.Ptr("1.2.3.6"), + SubnetMask: utils.Ptr("255.255.255.0"), }, - V6: &types.V6ServerConfJSON{}, + V6: &model.DhcpConfigV6{}, } Ω(dc1.HasConfig()).Should(BeTrue()) }) It("should not have a v6 config", func() { - dc1 := &types.DHCPServerConfig{ - V4: &types.V4ServerConfJSON{}, - V6: &types.V6ServerConfJSON{ - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), + dc1 := &model.DhcpStatus{ + V4: &model.DhcpConfigV4{}, + V6: &model.DhcpConfigV6{ + RangeStart: utils.Ptr("1.2.3.5"), }, } Ω(dc1.HasConfig()).Should(BeTrue()) diff --git a/pkg/mocks/client/mock.go b/pkg/mocks/client/mock.go index 73859f5..b985c25 100644 --- a/pkg/mocks/client/mock.go +++ b/pkg/mocks/client/mock.go @@ -7,7 +7,7 @@ package client import ( reflect "reflect" - types "github.com/bakito/adguardhome-sync/pkg/types" + model "github.com/bakito/adguardhome-sync/pkg/client/model" gomock "github.com/golang/mock/gomock" ) @@ -35,10 +35,10 @@ func (m *MockClient) EXPECT() *MockClientMockRecorder { } // AccessList mocks base method. -func (m *MockClient) AccessList() (*types.AccessList, error) { +func (m *MockClient) AccessList() (*model.AccessList, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "AccessList") - ret0, _ := ret[0].(*types.AccessList) + ret0, _ := ret[0].(*model.AccessList) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -50,7 +50,7 @@ func (mr *MockClientMockRecorder) AccessList() *gomock.Call { } // AddClients mocks base method. -func (m *MockClient) AddClients(arg0 ...types.Client) error { +func (m *MockClient) AddClients(arg0 ...*model.Client) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -68,7 +68,7 @@ func (mr *MockClientMockRecorder) AddClients(arg0 ...interface{}) *gomock.Call { } // AddDHCPStaticLeases mocks base method. -func (m *MockClient) AddDHCPStaticLeases(arg0 ...types.Lease) error { +func (m *MockClient) AddDHCPStaticLeases(arg0 ...model.DhcpStaticLease) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -86,7 +86,7 @@ func (mr *MockClientMockRecorder) AddDHCPStaticLeases(arg0 ...interface{}) *gomo } // AddFilters mocks base method. -func (m *MockClient) AddFilters(arg0 bool, arg1 ...types.Filter) error { +func (m *MockClient) AddFilters(arg0 bool, arg1 ...model.Filter) error { m.ctrl.T.Helper() varargs := []interface{}{arg0} for _, a := range arg1 { @@ -105,7 +105,7 @@ func (mr *MockClientMockRecorder) AddFilters(arg0 interface{}, arg1 ...interface } // AddRewriteEntries mocks base method. -func (m *MockClient) AddRewriteEntries(arg0 ...types.RewriteEntry) error { +func (m *MockClient) AddRewriteEntries(arg0 ...model.RewriteEntry) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -122,11 +122,41 @@ func (mr *MockClientMockRecorder) AddRewriteEntries(arg0 ...interface{}) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddRewriteEntries", reflect.TypeOf((*MockClient)(nil).AddRewriteEntries), arg0...) } +// BlockedServices mocks base method. +func (m *MockClient) BlockedServices() (*[]string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BlockedServices") + ret0, _ := ret[0].(*[]string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// BlockedServices indicates an expected call of BlockedServices. +func (mr *MockClientMockRecorder) BlockedServices() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockedServices", reflect.TypeOf((*MockClient)(nil).BlockedServices)) +} + +// BlockedServicesSchedule mocks base method. +func (m *MockClient) BlockedServicesSchedule() (*model.BlockedServicesSchedule, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BlockedServicesSchedule") + ret0, _ := ret[0].(*model.BlockedServicesSchedule) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// BlockedServicesSchedule indicates an expected call of BlockedServicesSchedule. +func (mr *MockClientMockRecorder) BlockedServicesSchedule() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BlockedServicesSchedule", reflect.TypeOf((*MockClient)(nil).BlockedServicesSchedule)) +} + // Clients mocks base method. -func (m *MockClient) Clients() (*types.Clients, error) { +func (m *MockClient) Clients() (*model.Clients, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Clients") - ret0, _ := ret[0].(*types.Clients) + ret0, _ := ret[0].(*model.Clients) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -137,26 +167,11 @@ func (mr *MockClientMockRecorder) Clients() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clients", reflect.TypeOf((*MockClient)(nil).Clients)) } -// DHCPServerConfig mocks base method. -func (m *MockClient) DHCPServerConfig() (*types.DHCPServerConfig, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DHCPServerConfig") - ret0, _ := ret[0].(*types.DHCPServerConfig) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DHCPServerConfig indicates an expected call of DHCPServerConfig. -func (mr *MockClientMockRecorder) DHCPServerConfig() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DHCPServerConfig", reflect.TypeOf((*MockClient)(nil).DHCPServerConfig)) -} - // DNSConfig mocks base method. -func (m *MockClient) DNSConfig() (*types.DNSConfig, error) { +func (m *MockClient) DNSConfig() (*model.DNSConfig, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DNSConfig") - ret0, _ := ret[0].(*types.DNSConfig) + ret0, _ := ret[0].(*model.DNSConfig) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -168,7 +183,7 @@ func (mr *MockClientMockRecorder) DNSConfig() *gomock.Call { } // DeleteClients mocks base method. -func (m *MockClient) DeleteClients(arg0 ...types.Client) error { +func (m *MockClient) DeleteClients(arg0 ...*model.Client) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -186,7 +201,7 @@ func (mr *MockClientMockRecorder) DeleteClients(arg0 ...interface{}) *gomock.Cal } // DeleteDHCPStaticLeases mocks base method. -func (m *MockClient) DeleteDHCPStaticLeases(arg0 ...types.Lease) error { +func (m *MockClient) DeleteDHCPStaticLeases(arg0 ...model.DhcpStaticLease) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -204,7 +219,7 @@ func (mr *MockClientMockRecorder) DeleteDHCPStaticLeases(arg0 ...interface{}) *g } // DeleteFilters mocks base method. -func (m *MockClient) DeleteFilters(arg0 bool, arg1 ...types.Filter) error { +func (m *MockClient) DeleteFilters(arg0 bool, arg1 ...model.Filter) error { m.ctrl.T.Helper() varargs := []interface{}{arg0} for _, a := range arg1 { @@ -223,7 +238,7 @@ func (mr *MockClientMockRecorder) DeleteFilters(arg0 interface{}, arg1 ...interf } // DeleteRewriteEntries mocks base method. -func (m *MockClient) DeleteRewriteEntries(arg0 ...types.RewriteEntry) error { +func (m *MockClient) DeleteRewriteEntries(arg0 ...model.RewriteEntry) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -240,11 +255,26 @@ func (mr *MockClientMockRecorder) DeleteRewriteEntries(arg0 ...interface{}) *gom return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteRewriteEntries", reflect.TypeOf((*MockClient)(nil).DeleteRewriteEntries), arg0...) } +// DhcpConfig mocks base method. +func (m *MockClient) DhcpConfig() (*model.DhcpStatus, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DhcpConfig") + ret0, _ := ret[0].(*model.DhcpStatus) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DhcpConfig indicates an expected call of DhcpConfig. +func (mr *MockClientMockRecorder) DhcpConfig() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DhcpConfig", reflect.TypeOf((*MockClient)(nil).DhcpConfig)) +} + // Filtering mocks base method. -func (m *MockClient) Filtering() (*types.FilteringStatus, error) { +func (m *MockClient) Filtering() (*model.FilterStatus, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Filtering") - ret0, _ := ret[0].(*types.FilteringStatus) + ret0, _ := ret[0].(*model.FilterStatus) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -284,11 +314,26 @@ func (mr *MockClientMockRecorder) Parental() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Parental", reflect.TypeOf((*MockClient)(nil).Parental)) } +// ProfileInfo mocks base method. +func (m *MockClient) ProfileInfo() (*model.ProfileInfo, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ProfileInfo") + ret0, _ := ret[0].(*model.ProfileInfo) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ProfileInfo indicates an expected call of ProfileInfo. +func (mr *MockClientMockRecorder) ProfileInfo() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProfileInfo", reflect.TypeOf((*MockClient)(nil).ProfileInfo)) +} + // QueryLogConfig mocks base method. -func (m *MockClient) QueryLogConfig() (*types.QueryLogConfig, error) { +func (m *MockClient) QueryLogConfig() (*model.QueryLogConfig, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "QueryLogConfig") - ret0, _ := ret[0].(*types.QueryLogConfig) + ret0, _ := ret[0].(*model.QueryLogConfig) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -314,10 +359,10 @@ func (mr *MockClientMockRecorder) RefreshFilters(arg0 interface{}) *gomock.Call } // RewriteList mocks base method. -func (m *MockClient) RewriteList() (*types.RewriteEntries, error) { +func (m *MockClient) RewriteList() (*model.RewriteEntries, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "RewriteList") - ret0, _ := ret[0].(*types.RewriteEntries) + ret0, _ := ret[0].(*model.RewriteEntries) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -343,38 +388,23 @@ func (mr *MockClientMockRecorder) SafeBrowsing() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SafeBrowsing", reflect.TypeOf((*MockClient)(nil).SafeBrowsing)) } -// SafeSearch mocks base method. -func (m *MockClient) SafeSearch() (bool, error) { +// SafeSearchConfig mocks base method. +func (m *MockClient) SafeSearchConfig() (*model.SafeSearchConfig, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SafeSearch") - ret0, _ := ret[0].(bool) + ret := m.ctrl.Call(m, "SafeSearchConfig") + ret0, _ := ret[0].(*model.SafeSearchConfig) ret1, _ := ret[1].(error) return ret0, ret1 } -// SafeSearch indicates an expected call of SafeSearch. -func (mr *MockClientMockRecorder) SafeSearch() *gomock.Call { +// SafeSearchConfig indicates an expected call of SafeSearchConfig. +func (mr *MockClientMockRecorder) SafeSearchConfig() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SafeSearch", reflect.TypeOf((*MockClient)(nil).SafeSearch)) -} - -// Services mocks base method. -func (m *MockClient) Services() (types.Services, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Services") - ret0, _ := ret[0].(types.Services) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Services indicates an expected call of Services. -func (mr *MockClientMockRecorder) Services() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Services", reflect.TypeOf((*MockClient)(nil).Services)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SafeSearchConfig", reflect.TypeOf((*MockClient)(nil).SafeSearchConfig)) } // SetAccessList mocks base method. -func (m *MockClient) SetAccessList(arg0 *types.AccessList) error { +func (m *MockClient) SetAccessList(arg0 *model.AccessList) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetAccessList", arg0) ret0, _ := ret[0].(error) @@ -387,8 +417,36 @@ func (mr *MockClientMockRecorder) SetAccessList(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccessList", reflect.TypeOf((*MockClient)(nil).SetAccessList), arg0) } +// SetBlockedServices mocks base method. +func (m *MockClient) SetBlockedServices(arg0 *[]string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetBlockedServices", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetBlockedServices indicates an expected call of SetBlockedServices. +func (mr *MockClientMockRecorder) SetBlockedServices(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBlockedServices", reflect.TypeOf((*MockClient)(nil).SetBlockedServices), arg0) +} + +// SetBlockedServicesSchedule mocks base method. +func (m *MockClient) SetBlockedServicesSchedule(arg0 *model.BlockedServicesSchedule) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetBlockedServicesSchedule", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetBlockedServicesSchedule indicates an expected call of SetBlockedServicesSchedule. +func (mr *MockClientMockRecorder) SetBlockedServicesSchedule(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBlockedServicesSchedule", reflect.TypeOf((*MockClient)(nil).SetBlockedServicesSchedule), arg0) +} + // SetCustomRules mocks base method. -func (m *MockClient) SetCustomRules(arg0 types.UserRules) error { +func (m *MockClient) SetCustomRules(arg0 *[]string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetCustomRules", arg0) ret0, _ := ret[0].(error) @@ -401,22 +459,8 @@ func (mr *MockClientMockRecorder) SetCustomRules(arg0 interface{}) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCustomRules", reflect.TypeOf((*MockClient)(nil).SetCustomRules), arg0) } -// SetDHCPServerConfig mocks base method. -func (m *MockClient) SetDHCPServerConfig(arg0 *types.DHCPServerConfig) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetDHCPServerConfig", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// SetDHCPServerConfig indicates an expected call of SetDHCPServerConfig. -func (mr *MockClientMockRecorder) SetDHCPServerConfig(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDHCPServerConfig", reflect.TypeOf((*MockClient)(nil).SetDHCPServerConfig), arg0) -} - // SetDNSConfig mocks base method. -func (m *MockClient) SetDNSConfig(arg0 *types.DNSConfig) error { +func (m *MockClient) SetDNSConfig(arg0 *model.DNSConfig) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetDNSConfig", arg0) ret0, _ := ret[0].(error) @@ -429,36 +473,64 @@ func (mr *MockClientMockRecorder) SetDNSConfig(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDNSConfig", reflect.TypeOf((*MockClient)(nil).SetDNSConfig), arg0) } -// SetQueryLogConfig mocks base method. -func (m *MockClient) SetQueryLogConfig(arg0 bool, arg1 float64, arg2 bool) error { +// SetDhcpConfig mocks base method. +func (m *MockClient) SetDhcpConfig(arg0 *model.DhcpStatus) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetQueryLogConfig", arg0, arg1, arg2) + ret := m.ctrl.Call(m, "SetDhcpConfig", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetDhcpConfig indicates an expected call of SetDhcpConfig. +func (mr *MockClientMockRecorder) SetDhcpConfig(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDhcpConfig", reflect.TypeOf((*MockClient)(nil).SetDhcpConfig), arg0) +} + +// SetProfileInfo mocks base method. +func (m *MockClient) SetProfileInfo(arg0 *model.ProfileInfo) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetProfileInfo", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetProfileInfo indicates an expected call of SetProfileInfo. +func (mr *MockClientMockRecorder) SetProfileInfo(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetProfileInfo", reflect.TypeOf((*MockClient)(nil).SetProfileInfo), arg0) +} + +// SetQueryLogConfig mocks base method. +func (m *MockClient) SetQueryLogConfig(arg0 *model.QueryLogConfig) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetQueryLogConfig", arg0) ret0, _ := ret[0].(error) return ret0 } // SetQueryLogConfig indicates an expected call of SetQueryLogConfig. -func (mr *MockClientMockRecorder) SetQueryLogConfig(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockClientMockRecorder) SetQueryLogConfig(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetQueryLogConfig", reflect.TypeOf((*MockClient)(nil).SetQueryLogConfig), arg0, arg1, arg2) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetQueryLogConfig", reflect.TypeOf((*MockClient)(nil).SetQueryLogConfig), arg0) } -// SetServices mocks base method. -func (m *MockClient) SetServices(arg0 types.Services) error { +// SetSafeSearchConfig mocks base method. +func (m *MockClient) SetSafeSearchConfig(arg0 *model.SafeSearchConfig) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "SetServices", arg0) + ret := m.ctrl.Call(m, "SetSafeSearchConfig", arg0) ret0, _ := ret[0].(error) return ret0 } -// SetServices indicates an expected call of SetServices. -func (mr *MockClientMockRecorder) SetServices(arg0 interface{}) *gomock.Call { +// SetSafeSearchConfig indicates an expected call of SetSafeSearchConfig. +func (mr *MockClientMockRecorder) SetSafeSearchConfig(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetServices", reflect.TypeOf((*MockClient)(nil).SetServices), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSafeSearchConfig", reflect.TypeOf((*MockClient)(nil).SetSafeSearchConfig), arg0) } // SetStatsConfig mocks base method. -func (m *MockClient) SetStatsConfig(arg0 float64) error { +func (m *MockClient) SetStatsConfig(arg0 *model.StatsConfig) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "SetStatsConfig", arg0) ret0, _ := ret[0].(error) @@ -486,10 +558,10 @@ func (mr *MockClientMockRecorder) Setup() *gomock.Call { } // StatsConfig mocks base method. -func (m *MockClient) StatsConfig() (*types.IntervalConfig, error) { +func (m *MockClient) StatsConfig() (*model.StatsConfig, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "StatsConfig") - ret0, _ := ret[0].(*types.IntervalConfig) + ret0, _ := ret[0].(*model.StatsConfig) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -501,10 +573,10 @@ func (mr *MockClientMockRecorder) StatsConfig() *gomock.Call { } // Status mocks base method. -func (m *MockClient) Status() (*types.Status, error) { +func (m *MockClient) Status() (*model.ServerStatus, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Status") - ret0, _ := ret[0].(*types.Status) + ret0, _ := ret[0].(*model.ServerStatus) ret1, _ := ret[1].(error) return ret0, ret1 } @@ -516,7 +588,7 @@ func (mr *MockClientMockRecorder) Status() *gomock.Call { } // ToggleFiltering mocks base method. -func (m *MockClient) ToggleFiltering(arg0 bool, arg1 float64) error { +func (m *MockClient) ToggleFiltering(arg0 bool, arg1 int) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ToggleFiltering", arg0, arg1) ret0, _ := ret[0].(error) @@ -571,22 +643,8 @@ func (mr *MockClientMockRecorder) ToggleSafeBrowsing(arg0 interface{}) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleSafeBrowsing", reflect.TypeOf((*MockClient)(nil).ToggleSafeBrowsing), arg0) } -// ToggleSafeSearch mocks base method. -func (m *MockClient) ToggleSafeSearch(arg0 bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ToggleSafeSearch", arg0) - ret0, _ := ret[0].(error) - return ret0 -} - -// ToggleSafeSearch indicates an expected call of ToggleSafeSearch. -func (mr *MockClientMockRecorder) ToggleSafeSearch(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ToggleSafeSearch", reflect.TypeOf((*MockClient)(nil).ToggleSafeSearch), arg0) -} - // UpdateClients mocks base method. -func (m *MockClient) UpdateClients(arg0 ...types.Client) error { +func (m *MockClient) UpdateClients(arg0 ...*model.Client) error { m.ctrl.T.Helper() varargs := []interface{}{} for _, a := range arg0 { @@ -604,7 +662,7 @@ func (mr *MockClientMockRecorder) UpdateClients(arg0 ...interface{}) *gomock.Cal } // UpdateFilters mocks base method. -func (m *MockClient) UpdateFilters(arg0 bool, arg1 ...types.Filter) error { +func (m *MockClient) UpdateFilters(arg0 bool, arg1 ...model.Filter) error { m.ctrl.T.Helper() varargs := []interface{}{arg0} for _, a := range arg1 { diff --git a/pkg/sync/http.go b/pkg/sync/http.go index f81e7e6..68cbd06 100644 --- a/pkg/sync/http.go +++ b/pkg/sync/http.go @@ -33,9 +33,10 @@ func (w *worker) handleSync(c *gin.Context) { func (w *worker) handleRoot(c *gin.Context) { c.HTML(http.StatusOK, "index.html", map[string]interface{}{ - "DarkMode": w.cfg.API.DarkMode, - "Version": version.Version, - "Build": version.Build, + "DarkMode": w.cfg.API.DarkMode, + "Version": version.Version, + "Build": version.Build, + "SyncStatus": w.status(), }, ) } @@ -48,6 +49,10 @@ func (w *worker) handleLogs(c *gin.Context) { c.Data(http.StatusOK, "text/plain", []byte(strings.Join(log.Logs(), ""))) } +func (w *worker) handleStatus(c *gin.Context) { + c.JSON(http.StatusOK, w.status()) +} + func (w *worker) listenAndServe() { l.With("port", w.cfg.API.Port).Info("Starting API server") @@ -69,6 +74,7 @@ func (w *worker) listenAndServe() { r.SetHTMLTemplate(template.Must(template.New("index.html").Parse(string(index)))) r.POST("/api/v1/sync", w.handleSync) r.GET("/api/v1/logs", w.handleLogs) + r.GET("/api/v1/status", w.handleStatus) r.GET("/favicon.ico", w.handleFavicon) r.GET("/", w.handleRoot) @@ -115,3 +121,14 @@ func (w *worker) listenAndServe() { defer os.Exit(0) } + +type syncStatus struct { + Origin replicaStatus `json:"origin"` + Replicas []replicaStatus `json:"replicas"` +} + +type replicaStatus struct { + Host string `json:"origin"` + Status string `json:"status"` + Error string `json:"error,omitempty"` +} diff --git a/pkg/sync/index.html b/pkg/sync/index.html index 709226c..e8a0fa9 100644 --- a/pkg/sync/index.html +++ b/pkg/sync/index.html @@ -1,4 +1,4 @@ - + AdGuardHome sync -
+
-

AdGuardHome sync -

{{ .Version }} ({{ .Build }})

+

+ AdGuardHome sync +

{{ .Version }} ({{ .Build }})

+

@@ -41,6 +55,16 @@
+
+
+ + {{ range $i, $r := .SyncStatus.Replicas }} + + {{ end }} +
+
diff --git a/pkg/sync/sync.go b/pkg/sync/sync.go index d246959..2c245a6 100644 --- a/pkg/sync/sync.go +++ b/pkg/sync/sync.go @@ -4,11 +4,14 @@ import ( "errors" "fmt" "runtime" + "sort" "time" "github.com/bakito/adguardhome-sync/pkg/client" + "github.com/bakito/adguardhome-sync/pkg/client/model" "github.com/bakito/adguardhome-sync/pkg/log" "github.com/bakito/adguardhome-sync/pkg/types" + "github.com/bakito/adguardhome-sync/pkg/utils" "github.com/bakito/adguardhome-sync/pkg/versions" "github.com/bakito/adguardhome-sync/version" "github.com/robfig/cron/v3" @@ -89,6 +92,45 @@ type worker struct { createClient func(instance types.AdGuardInstance) (client.Client, error) } +func (w *worker) status() *syncStatus { + syncStatus := &syncStatus{ + Origin: w.getStatus(w.cfg.Origin), + } + + for _, replica := range w.cfg.Replicas { + st := w.getStatus(replica) + if w.running { + st.Status = "info" + } + syncStatus.Replicas = append(syncStatus.Replicas, st) + } + + sort.Slice(syncStatus.Replicas, func(i, j int) bool { + return syncStatus.Replicas[i].Host < syncStatus.Replicas[j].Host + }) + + return syncStatus +} + +func (w *worker) getStatus(inst types.AdGuardInstance) replicaStatus { + oc, err := w.createClient(inst) + if err != nil { + l.With("error", err, "url", w.cfg.Origin.URL).Error("Error creating origin client") + return replicaStatus{Host: oc.Host(), Error: err.Error(), Status: "danger"} + } + sl := l.With("from", oc.Host()) + _, err = oc.Status() + if err != nil { + if errors.Is(err, client.ErrSetupNeeded) { + return replicaStatus{Host: oc.Host(), Error: err.Error(), Status: "warning"} + } + sl.With("error", err).Error("Error getting origin status") + return replicaStatus{Host: oc.Host(), Error: err.Error(), Status: "danger"} + } + st := replicaStatus{Host: oc.Host(), Status: "success"} + return st +} + func (w *worker) sync() { if w.running { l.Info("Sync already running") @@ -119,12 +161,18 @@ func (w *worker) sync() { sl.With("version", o.status.Version).Info("Connected to origin") + o.profileInfo, err = oc.ProfileInfo() + if err != nil { + sl.With("error", err).Error("Error getting profileInfo info") + return + } + o.parental, err = oc.Parental() if err != nil { sl.With("error", err).Error("Error getting parental status") return } - o.safeSearch, err = oc.SafeSearch() + o.safeSearch, err = oc.SafeSearchConfig() if err != nil { sl.With("error", err).Error("Error getting safe search status") return @@ -141,9 +189,15 @@ func (w *worker) sync() { return } - o.services, err = oc.Services() + o.blockedServices, err = oc.BlockedServices() if err != nil { - sl.With("error", err).Error("Error getting origin services") + sl.With("error", err).Error("Error getting origin blocked services") + return + } + + o.blockedServicesSchedule, err = oc.BlockedServicesSchedule() + if err != nil { + sl.With("error", err).Error("Error getting origin blocked services schedule") return } @@ -181,7 +235,7 @@ func (w *worker) sync() { } if w.cfg.Features.DHCP.ServerConfig || w.cfg.Features.DHCP.StaticLeases { - o.dhcpServerConfig, err = oc.DHCPServerConfig() + o.dhcpServerConfig, err = oc.DhcpConfig() if err != nil { sl.With("error", err).Error("Error getting dhcp server config") return @@ -217,11 +271,6 @@ func (w *worker) syncTo(l *zap.SugaredLogger, o *origin, replica types.AdGuardIn return } - if versions.IsSame(rs.Version, versions.IncompatibleAPI) { - rl.With("error", err, "version", rs.Version).Errorf("Replica AdGuard Home runs with an incompatible API - Please ugrade to version %s or newer", versions.FixedIncompatibleAPI) - return - } - if o.status.Version != rs.Version { rl.With("originVersion", o.status.Version, "replicaVersion", rs.Version).Warn("Versions do not match") } @@ -249,9 +298,9 @@ func (w *worker) syncTo(l *zap.SugaredLogger, o *origin, replica types.AdGuardIn return } - err = w.syncServices(o.services, rc) + err = w.syncServices(o.blockedServices, o.blockedServicesSchedule, rc) if err != nil { - rl.With("error", err).Error("Error syncing services") + rl.With("error", err).Error("Error syncing blockedServices") return } @@ -275,7 +324,7 @@ func (w *worker) syncTo(l *zap.SugaredLogger, o *origin, replica types.AdGuardIn rl.Info("Sync done") } -func (w *worker) statusWithSetup(rl *zap.SugaredLogger, replica types.AdGuardInstance, rc client.Client) (*types.Status, error) { +func (w *worker) statusWithSetup(rl *zap.SugaredLogger, replica types.AdGuardInstance, rc client.Client) (*model.ServerStatus, error) { rs, err := rc.Status() if err != nil { if replica.AutoSetup && errors.Is(err, client.ErrSetupNeeded) { @@ -290,15 +339,26 @@ func (w *worker) statusWithSetup(rl *zap.SugaredLogger, replica types.AdGuardIns return rs, err } -func (w *worker) syncServices(os types.Services, replica client.Client) error { +func (w *worker) syncServices(os *model.BlockedServicesArray, obss *model.BlockedServicesSchedule, replica client.Client) error { if w.cfg.Features.Services { - rs, err := replica.Services() + rs, err := replica.BlockedServices() if err != nil { return err } - if !os.Equals(rs) { - if err := replica.SetServices(os); err != nil { + if !model.EqualsStringSlice(os, rs, true) { + if err := replica.SetBlockedServices(os); err != nil { + return err + } + } + + rbss, err := replica.BlockedServicesSchedule() + if err != nil { + return err + } + + if !obss.Equals(rbss) { + if err := replica.SetBlockedServicesSchedule(obss); err != nil { return err } } @@ -306,7 +366,7 @@ func (w *worker) syncServices(os types.Services, replica client.Client) error { return nil } -func (w *worker) syncFilters(of *types.FilteringStatus, replica client.Client) error { +func (w *worker) syncFilters(of *model.FilterStatus, replica client.Client) error { if w.cfg.Features.Filters { rf, err := replica.Filtering() if err != nil { @@ -320,12 +380,12 @@ func (w *worker) syncFilters(of *types.FilteringStatus, replica client.Client) e return err } - if of.UserRules.String() != rf.UserRules.String() { + if utils.PtrToString(of.UserRules) != utils.PtrToString(rf.UserRules) { return replica.SetCustomRules(of.UserRules) } if of.Enabled != rf.Enabled || of.Interval != rf.Interval { - if err = replica.ToggleFiltering(of.Enabled, of.Interval); err != nil { + if err = replica.ToggleFiltering(*of.Enabled, *of.Interval); err != nil { return err } } @@ -333,8 +393,8 @@ func (w *worker) syncFilters(of *types.FilteringStatus, replica client.Client) e return nil } -func (w *worker) syncFilterType(of types.Filters, rFilters types.Filters, whitelist bool, replica client.Client) error { - fa, fu, fd := rFilters.Merge(of) +func (w *worker) syncFilterType(of *[]model.Filter, rFilters *[]model.Filter, whitelist bool, replica client.Client) error { + fa, fu, fd := model.MergeFilters(rFilters, of) if err := replica.DeleteFilters(whitelist, fd...); err != nil { return err @@ -354,7 +414,7 @@ func (w *worker) syncFilterType(of types.Filters, rFilters types.Filters, whitel return nil } -func (w *worker) syncRewrites(rl *zap.SugaredLogger, or *types.RewriteEntries, replica client.Client) error { +func (w *worker) syncRewrites(rl *zap.SugaredLogger, or *model.RewriteEntries, replica client.Client) error { if w.cfg.Features.DNS.Rewrites { replicaRewrites, err := replica.RewriteList() if err != nil { @@ -378,7 +438,7 @@ func (w *worker) syncRewrites(rl *zap.SugaredLogger, or *types.RewriteEntries, r return nil } -func (w *worker) syncClients(oc *types.Clients, replica client.Client) error { +func (w *worker) syncClients(oc *model.Clients, replica client.Client) error { if w.cfg.Features.ClientSettings { rc, err := replica.Clients() if err != nil { @@ -400,8 +460,17 @@ func (w *worker) syncClients(oc *types.Clients, replica client.Client) error { return nil } -func (w *worker) syncGeneralSettings(o *origin, rs *types.Status, replica client.Client) error { +func (w *worker) syncGeneralSettings(o *origin, rs *model.ServerStatus, replica client.Client) error { if w.cfg.Features.GeneralSettings { + + if pro, err := replica.ProfileInfo(); err != nil { + return err + } else if !o.profileInfo.Equals(pro) { + if err = replica.SetProfileInfo(o.profileInfo); err != nil { + return err + } + } + if o.status.ProtectionEnabled != rs.ProtectionEnabled { if err := replica.ToggleProtection(o.status.ProtectionEnabled); err != nil { return err @@ -414,10 +483,10 @@ func (w *worker) syncGeneralSettings(o *origin, rs *types.Status, replica client return err } } - if rs, err := replica.SafeSearch(); err != nil { + if ssc, err := replica.SafeSearchConfig(); err != nil { return err - } else if o.safeSearch != rs { - if err = replica.ToggleSafeSearch(o.safeSearch); err != nil { + } else if !o.safeSearch.Equals(ssc) { + if err = replica.SetSafeSearchConfig(o.safeSearch); err != nil { return err } } @@ -439,7 +508,7 @@ func (w *worker) syncConfigs(o *origin, rc client.Client) error { return err } if !o.queryLogConfig.Equals(qlc) { - if err = rc.SetQueryLogConfig(o.queryLogConfig.Enabled, o.queryLogConfig.Interval, o.queryLogConfig.AnonymizeClientIP); err != nil { + if err = rc.SetQueryLogConfig(o.queryLogConfig); err != nil { return err } } @@ -450,7 +519,7 @@ func (w *worker) syncConfigs(o *origin, rc client.Client) error { return err } if o.statsConfig.Interval != sc.Interval { - if err = rc.SetStatsConfig(o.statsConfig.Interval); err != nil { + if err = rc.SetStatsConfig(o.statsConfig); err != nil { return err } } @@ -459,7 +528,7 @@ func (w *worker) syncConfigs(o *origin, rc client.Client) error { return nil } -func (w *worker) syncDNS(oal *types.AccessList, odc *types.DNSConfig, rc client.Client) error { +func (w *worker) syncDNS(oal *model.AccessList, odc *model.DNSConfig, rc client.Client) error { if w.cfg.Features.DNS.AccessLists { al, err := rc.AccessList() if err != nil { @@ -485,11 +554,11 @@ func (w *worker) syncDNS(oal *types.AccessList, odc *types.DNSConfig, rc client. return nil } -func (w *worker) syncDHCPServer(osc *types.DHCPServerConfig, rc client.Client, replica types.AdGuardInstance) error { +func (w *worker) syncDHCPServer(osc *model.DhcpStatus, rc client.Client, replica types.AdGuardInstance) error { if !w.cfg.Features.DHCP.ServerConfig && !w.cfg.Features.DHCP.StaticLeases { return nil } - sc, err := rc.DHCPServerConfig() + sc, err := rc.DhcpConfig() if w.cfg.Features.DHCP.ServerConfig && osc.HasConfig() { if err != nil { return err @@ -497,22 +566,22 @@ func (w *worker) syncDHCPServer(osc *types.DHCPServerConfig, rc client.Client, r origClone := osc.Clone() if replica.InterfaceName != "" { // overwrite interface name - origClone.InterfaceName = replica.InterfaceName + origClone.InterfaceName = utils.Ptr(replica.InterfaceName) } if replica.DHCPServerEnabled != nil { // overwrite dhcp enabled - origClone.Enabled = *replica.DHCPServerEnabled + origClone.Enabled = replica.DHCPServerEnabled } if !sc.Equals(origClone) { - if err = rc.SetDHCPServerConfig(origClone); err != nil { + if err = rc.SetDhcpConfig(origClone); err != nil { return err } } } if w.cfg.Features.DHCP.StaticLeases { - a, r := sc.StaticLeases.Merge(osc.StaticLeases) + a, r := model.MergeDhcpStaticLeases(sc.StaticLeases, osc.StaticLeases) if err = rc.DeleteDHCPStaticLeases(r...); err != nil { return err @@ -525,17 +594,19 @@ func (w *worker) syncDHCPServer(osc *types.DHCPServerConfig, rc client.Client, r } type origin struct { - status *types.Status - rewrites *types.RewriteEntries - services types.Services - filters *types.FilteringStatus - clients *types.Clients - queryLogConfig *types.QueryLogConfig - statsConfig *types.IntervalConfig - accessList *types.AccessList - dnsConfig *types.DNSConfig - dhcpServerConfig *types.DHCPServerConfig - parental bool - safeSearch bool - safeBrowsing bool + status *model.ServerStatus + rewrites *model.RewriteEntries + blockedServices *model.BlockedServicesArray + blockedServicesSchedule *model.BlockedServicesSchedule + filters *model.FilterStatus + clients *model.Clients + queryLogConfig *model.QueryLogConfig + statsConfig *model.StatsConfig + accessList *model.AccessList + dnsConfig *model.DNSConfig + dhcpServerConfig *model.DhcpStatus + parental bool + safeSearch *model.SafeSearchConfig + profileInfo *model.ProfileInfo + safeBrowsing bool } diff --git a/pkg/sync/sync_test.go b/pkg/sync/sync_test.go index 677407b..067e8e6 100644 --- a/pkg/sync/sync_test.go +++ b/pkg/sync/sync_test.go @@ -2,11 +2,12 @@ package sync import ( "errors" - "net" "github.com/bakito/adguardhome-sync/pkg/client" + "github.com/bakito/adguardhome-sync/pkg/client/model" clientmock "github.com/bakito/adguardhome-sync/pkg/mocks/client" "github.com/bakito/adguardhome-sync/pkg/types" + "github.com/bakito/adguardhome-sync/pkg/utils" "github.com/bakito/adguardhome-sync/pkg/versions" gm "github.com/golang/mock/gomock" "github.com/google/uuid" @@ -62,15 +63,15 @@ var _ = Describe("Sync", func() { var ( domain string answer string - reO types.RewriteEntries - reR types.RewriteEntries + reO model.RewriteEntries + reR model.RewriteEntries ) BeforeEach(func() { domain = uuid.NewString() answer = uuid.NewString() - reO = []types.RewriteEntry{{Domain: domain, Answer: answer}} - reR = []types.RewriteEntry{{Domain: domain, Answer: answer}} + reO = []model.RewriteEntry{{Domain: utils.Ptr(domain), Answer: utils.Ptr(answer)}} + reR = []model.RewriteEntry{{Domain: utils.Ptr(domain), Answer: utils.Ptr(answer)}} }) It("should have no changes (empty slices)", func() { cl.EXPECT().RewriteList().Return(&reR, nil) @@ -80,7 +81,7 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should add one rewrite entry", func() { - reR = []types.RewriteEntry{} + reR = []model.RewriteEntry{} cl.EXPECT().RewriteList().Return(&reR, nil) cl.EXPECT().AddRewriteEntries(reO[0]) cl.EXPECT().DeleteRewriteEntries() @@ -88,7 +89,7 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should remove one rewrite entry", func() { - reO = []types.RewriteEntry{} + reO = []model.RewriteEntry{} cl.EXPECT().RewriteList().Return(&reR, nil) cl.EXPECT().AddRewriteEntries() cl.EXPECT().DeleteRewriteEntries(reR[0]) @@ -96,7 +97,7 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should remove one rewrite entry", func() { - reO = []types.RewriteEntry{} + reO = []model.RewriteEntry{} cl.EXPECT().RewriteList().Return(&reR, nil) cl.EXPECT().AddRewriteEntries() cl.EXPECT().DeleteRewriteEntries(reR[0]) @@ -124,14 +125,14 @@ var _ = Describe("Sync", func() { }) Context("syncClients", func() { var ( - clO *types.Clients - clR *types.Clients + clO *model.Clients + clR *model.Clients name string ) BeforeEach(func() { name = uuid.NewString() - clO = &types.Clients{Clients: []types.Client{{Name: name}}} - clR = &types.Clients{Clients: []types.Client{{Name: name}}} + clO = &model.Clients{Clients: &model.ClientsArray{{Name: utils.Ptr(name)}}} + clR = &model.Clients{Clients: &model.ClientsArray{{Name: utils.Ptr(name)}}} }) It("should have no changes (empty slices)", func() { cl.EXPECT().Clients().Return(clR, nil) @@ -142,29 +143,29 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should add one client", func() { - clR.Clients = []types.Client{} + clR.Clients = &model.ClientsArray{} cl.EXPECT().Clients().Return(clR, nil) - cl.EXPECT().AddClients(clO.Clients[0]) + cl.EXPECT().AddClients(&(*clO.Clients)[0]) cl.EXPECT().UpdateClients() cl.EXPECT().DeleteClients() err := w.syncClients(clO, cl) Ω(err).ShouldNot(HaveOccurred()) }) It("should update one client", func() { - clR.Clients[0].Disallowed = true + (*clR.Clients)[0].FilteringEnabled = utils.Ptr(true) cl.EXPECT().Clients().Return(clR, nil) cl.EXPECT().AddClients() - cl.EXPECT().UpdateClients(clO.Clients[0]) + cl.EXPECT().UpdateClients(&(*clO.Clients)[0]) cl.EXPECT().DeleteClients() err := w.syncClients(clO, cl) Ω(err).ShouldNot(HaveOccurred()) }) It("should delete one client", func() { - clO.Clients = []types.Client{} + clO.Clients = &model.ClientsArray{} cl.EXPECT().Clients().Return(clR, nil) cl.EXPECT().AddClients() cl.EXPECT().UpdateClients() - cl.EXPECT().DeleteClients(clR.Clients[0]) + cl.EXPECT().DeleteClients(&(*clR.Clients)[0]) err := w.syncClients(clO, cl) Ω(err).ShouldNot(HaveOccurred()) }) @@ -198,17 +199,23 @@ var _ = Describe("Sync", func() { Context("syncGeneralSettings", func() { var ( o *origin - rs *types.Status + rs *model.ServerStatus ) BeforeEach(func() { o = &origin{ - status: &types.Status{}, + profileInfo: &model.ProfileInfo{ + Name: "test", + Language: "en", + }, + status: &model.ServerStatus{}, + safeSearch: &model.SafeSearchConfig{}, } - rs = &types.Status{} + rs = &model.ServerStatus{} }) It("should have no changes", func() { cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().ProfileInfo().Return(o.profileInfo, nil) + cl.EXPECT().SafeSearchConfig().Return(o.safeSearch, nil) cl.EXPECT().SafeBrowsing() err := w.syncGeneralSettings(o, rs, cl) Ω(err).ShouldNot(HaveOccurred()) @@ -217,7 +224,8 @@ var _ = Describe("Sync", func() { o.status.ProtectionEnabled = true cl.EXPECT().ToggleProtection(true) cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().ProfileInfo().Return(o.profileInfo, nil) + cl.EXPECT().SafeSearchConfig().Return(o.safeSearch, nil) cl.EXPECT().SafeBrowsing() err := w.syncGeneralSettings(o, rs, cl) Ω(err).ShouldNot(HaveOccurred()) @@ -226,24 +234,48 @@ var _ = Describe("Sync", func() { o.parental = true cl.EXPECT().Parental() cl.EXPECT().ToggleParental(true) - cl.EXPECT().SafeSearch() + cl.EXPECT().ProfileInfo().Return(o.profileInfo, nil) + cl.EXPECT().SafeSearchConfig().Return(o.safeSearch, nil) cl.EXPECT().SafeBrowsing() err := w.syncGeneralSettings(o, rs, cl) Ω(err).ShouldNot(HaveOccurred()) }) It("should have safeSearch enabled changes", func() { - o.safeSearch = true + o.safeSearch = &model.SafeSearchConfig{Enabled: utils.Ptr(true)} cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() - cl.EXPECT().ToggleSafeSearch(true) + cl.EXPECT().SafeSearchConfig().Return(&model.SafeSearchConfig{}, nil) + cl.EXPECT().ProfileInfo().Return(o.profileInfo, nil) + cl.EXPECT().SetSafeSearchConfig(o.safeSearch) cl.EXPECT().SafeBrowsing() err := w.syncGeneralSettings(o, rs, cl) Ω(err).ShouldNot(HaveOccurred()) }) + It("should have Duckduckgo safeSearch enabled changed", func() { + o.safeSearch = &model.SafeSearchConfig{Duckduckgo: utils.Ptr(true)} + cl.EXPECT().Parental() + cl.EXPECT().ProfileInfo().Return(o.profileInfo, nil) + cl.EXPECT().SafeSearchConfig().Return(&model.SafeSearchConfig{Google: utils.Ptr(true)}, nil) + cl.EXPECT().SafeBrowsing() + cl.EXPECT().SetSafeSearchConfig(o.safeSearch) + + err := w.syncGeneralSettings(o, rs, cl) + Ω(err).ShouldNot(HaveOccurred()) + }) + It("should have profileInfo language changed", func() { + o.profileInfo.Language = "de" + cl.EXPECT().Parental() + cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{Language: "en"}, nil) + cl.EXPECT().SafeSearchConfig().Return(o.safeSearch, nil) + cl.EXPECT().SafeBrowsing() + cl.EXPECT().SetProfileInfo(o.profileInfo) + err := w.syncGeneralSettings(o, rs, cl) + Ω(err).ShouldNot(HaveOccurred()) + }) It("should have safeBrowsing enabled changes", func() { o.safeBrowsing = true cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().ProfileInfo().Return(o.profileInfo, nil) + cl.EXPECT().SafeSearchConfig().Return(o.safeSearch, nil) cl.EXPECT().SafeBrowsing() cl.EXPECT().ToggleSafeBrowsing(true) err := w.syncGeneralSettings(o, rs, cl) @@ -253,16 +285,16 @@ var _ = Describe("Sync", func() { Context("syncConfigs", func() { var ( o *origin - qlc *types.QueryLogConfig - sc *types.IntervalConfig + qlc *model.QueryLogConfig + sc *model.StatsConfig ) BeforeEach(func() { o = &origin{ - queryLogConfig: &types.QueryLogConfig{}, - statsConfig: &types.IntervalConfig{}, + queryLogConfig: &model.QueryLogConfig{}, + statsConfig: &model.StatsConfig{}, } - qlc = &types.QueryLogConfig{} - sc = &types.IntervalConfig{} + qlc = &model.QueryLogConfig{} + sc = &model.StatsConfig{} }) It("should have no changes", func() { cl.EXPECT().QueryLogConfig().Return(qlc, nil) @@ -271,29 +303,31 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should have QueryLogConfig changes", func() { - o.queryLogConfig.Interval = 123 + var interval model.QueryLogConfigInterval = 123 + o.queryLogConfig.Interval = &interval cl.EXPECT().QueryLogConfig().Return(qlc, nil) - cl.EXPECT().SetQueryLogConfig(false, 123.0, false) + cl.EXPECT().SetQueryLogConfig(&model.QueryLogConfig{AnonymizeClientIp: nil, Interval: &interval, Enabled: nil}) cl.EXPECT().StatsConfig().Return(sc, nil) err := w.syncConfigs(o, cl) Ω(err).ShouldNot(HaveOccurred()) }) It("should have StatsConfig changes", func() { - o.statsConfig.Interval = 123 + var interval model.StatsConfigInterval = 123 + o.statsConfig.Interval = &interval cl.EXPECT().QueryLogConfig().Return(qlc, nil) cl.EXPECT().StatsConfig().Return(sc, nil) - cl.EXPECT().SetStatsConfig(123.0) + cl.EXPECT().SetStatsConfig(&model.StatsConfig{Interval: &interval}) err := w.syncConfigs(o, cl) Ω(err).ShouldNot(HaveOccurred()) }) }) Context("statusWithSetup", func() { var ( - status *types.Status + status *model.ServerStatus inst types.AdGuardInstance ) BeforeEach(func() { - status = &types.Status{} + status = &model.ServerStatus{} inst = types.AdGuardInstance{ AutoSetup: true, } @@ -322,34 +356,39 @@ var _ = Describe("Sync", func() { }) Context("syncServices", func() { var ( - os types.Services - rs types.Services + obs *model.BlockedServicesArray + rbs *model.BlockedServicesArray + obss *model.BlockedServicesSchedule ) BeforeEach(func() { - os = []string{"foo"} - rs = []string{"foo"} + obs = &model.BlockedServicesArray{"foo"} + rbs = &model.BlockedServicesArray{"foo"} + obss = &model.BlockedServicesSchedule{} }) It("should have no changes", func() { - cl.EXPECT().Services().Return(rs, nil) - err := w.syncServices(os, cl) + cl.EXPECT().BlockedServices().Return(rbs, nil) + cl.EXPECT().BlockedServicesSchedule().Return(obss, nil) + err := w.syncServices(obs, obss, cl) Ω(err).ShouldNot(HaveOccurred()) }) - It("should have services changes", func() { - os = []string{"bar"} - cl.EXPECT().Services().Return(rs, nil) - cl.EXPECT().SetServices(os) - err := w.syncServices(os, cl) + It("should have blockedServices changes", func() { + obs = &model.BlockedServicesArray{"bar"} + + cl.EXPECT().BlockedServices().Return(rbs, nil) + cl.EXPECT().BlockedServicesSchedule().Return(obss, nil) + cl.EXPECT().SetBlockedServices(obs) + err := w.syncServices(obs, obss, cl) Ω(err).ShouldNot(HaveOccurred()) }) }) Context("syncFilters", func() { var ( - of *types.FilteringStatus - rf *types.FilteringStatus + of *model.FilterStatus + rf *model.FilterStatus ) BeforeEach(func() { - of = &types.FilteringStatus{} - rf = &types.FilteringStatus{} + of = &model.FilterStatus{} + rf = &model.FilterStatus{} }) It("should have no changes", func() { cl.EXPECT().Filtering().Return(rf, nil) @@ -363,7 +402,7 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should have changes user roles", func() { - of.UserRules = []string{"foo"} + of.UserRules = utils.Ptr([]string{"foo"}) cl.EXPECT().Filtering().Return(rf, nil) cl.EXPECT().AddFilters(false) cl.EXPECT().UpdateFilters(false) @@ -376,8 +415,8 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should have changed filtering config", func() { - of.Enabled = true - of.Interval = 123 + of.Enabled = utils.Ptr(true) + of.Interval = utils.Ptr(123) cl.EXPECT().Filtering().Return(rf, nil) cl.EXPECT().AddFilters(false) cl.EXPECT().UpdateFilters(false) @@ -385,7 +424,7 @@ var _ = Describe("Sync", func() { cl.EXPECT().AddFilters(true) cl.EXPECT().UpdateFilters(true) cl.EXPECT().DeleteFilters(true) - cl.EXPECT().ToggleFiltering(of.Enabled, of.Interval) + cl.EXPECT().ToggleFiltering(*of.Enabled, *of.Interval) err := w.syncFilters(of, cl) Ω(err).ShouldNot(HaveOccurred()) }) @@ -393,16 +432,16 @@ var _ = Describe("Sync", func() { Context("syncDNS", func() { var ( - oal *types.AccessList - ral *types.AccessList - odc *types.DNSConfig - rdc *types.DNSConfig + oal *model.AccessList + ral *model.AccessList + odc *model.DNSConfig + rdc *model.DNSConfig ) BeforeEach(func() { - oal = &types.AccessList{} - ral = &types.AccessList{} - odc = &types.DNSConfig{} - rdc = &types.DNSConfig{} + oal = &model.AccessList{} + ral = &model.AccessList{} + odc = &model.DNSConfig{} + rdc = &model.DNSConfig{} }) It("should have no changes", func() { cl.EXPECT().AccessList().Return(ral, nil) @@ -411,7 +450,7 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should have access list changes", func() { - ral.BlockedHosts = []string{"foo"} + ral.BlockedHosts = utils.Ptr([]string{"foo"}) cl.EXPECT().AccessList().Return(ral, nil) cl.EXPECT().DNSConfig().Return(rdc, nil) cl.EXPECT().SetAccessList(oal) @@ -419,7 +458,7 @@ var _ = Describe("Sync", func() { Ω(err).ShouldNot(HaveOccurred()) }) It("should have dns config changes", func() { - rdc.Bootstraps = []string{"foo"} + rdc.BootstrapDns = utils.Ptr([]string{"foo"}) cl.EXPECT().AccessList().Return(ral, nil) cl.EXPECT().DNSConfig().Return(rdc, nil) cl.EXPECT().SetDNSConfig(odc) @@ -430,45 +469,45 @@ var _ = Describe("Sync", func() { Context("syncDHCPServer", func() { var ( - osc *types.DHCPServerConfig - rsc *types.DHCPServerConfig + osc *model.DhcpStatus + rsc *model.DhcpStatus ) BeforeEach(func() { - osc = &types.DHCPServerConfig{V4: &types.V4ServerConfJSON{ - GatewayIP: net.IPv4(1, 2, 3, 4), - RangeStart: net.IPv4(1, 2, 3, 5), - RangeEnd: net.IPv4(1, 2, 3, 6), - SubnetMask: net.IPv4(255, 255, 255, 0), + osc = &model.DhcpStatus{V4: &model.DhcpConfigV4{ + GatewayIp: utils.Ptr("1.2.3.4"), + RangeStart: utils.Ptr("1.2.3.5"), + RangeEnd: utils.Ptr("1.2.3.6"), + SubnetMask: utils.Ptr("255.255.255.0"), }} - rsc = &types.DHCPServerConfig{} + rsc = &model.DhcpStatus{} w.cfg.Features.DHCP.StaticLeases = false }) It("should have no changes", func() { rsc.V4 = osc.V4 - cl.EXPECT().DHCPServerConfig().Return(rsc, nil) + cl.EXPECT().DhcpConfig().Return(rsc, nil) err := w.syncDHCPServer(osc, cl, types.AdGuardInstance{}) Ω(err).ShouldNot(HaveOccurred()) }) It("should have changes", func() { - rsc.Enabled = true - cl.EXPECT().DHCPServerConfig().Return(rsc, nil) - cl.EXPECT().SetDHCPServerConfig(osc) + rsc.Enabled = utils.Ptr(true) + cl.EXPECT().DhcpConfig().Return(rsc, nil) + cl.EXPECT().SetDhcpConfig(osc) err := w.syncDHCPServer(osc, cl, types.AdGuardInstance{}) Ω(err).ShouldNot(HaveOccurred()) }) It("should use replica interface name", func() { - cl.EXPECT().DHCPServerConfig().Return(rsc, nil) + cl.EXPECT().DhcpConfig().Return(rsc, nil) oscClone := osc.Clone() - oscClone.InterfaceName = "foo" - cl.EXPECT().SetDHCPServerConfig(oscClone) + oscClone.InterfaceName = utils.Ptr("foo") + cl.EXPECT().SetDhcpConfig(oscClone) err := w.syncDHCPServer(osc, cl, types.AdGuardInstance{InterfaceName: "foo"}) Ω(err).ShouldNot(HaveOccurred()) }) It("should enable the target dhcp server", func() { - cl.EXPECT().DHCPServerConfig().Return(rsc, nil) + cl.EXPECT().DhcpConfig().Return(rsc, nil) oscClone := osc.Clone() - oscClone.Enabled = true - cl.EXPECT().SetDHCPServerConfig(oscClone) + oscClone.Enabled = utils.Ptr(true) + cl.EXPECT().SetDhcpConfig(oscClone) err := w.syncDHCPServer(osc, cl, types.AdGuardInstance{DHCPServerEnabled: &boolTrue}) Ω(err).ShouldNot(HaveOccurred()) }) @@ -501,46 +540,50 @@ var _ = Describe("Sync", func() { It("should have no changes", func() { // origin cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: versions.MinAgh}, nil) + cl.EXPECT().Status().Return(&model.ServerStatus{Version: versions.MinAgh}, nil) + cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{}, nil) cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().SafeSearchConfig().Return(&model.SafeSearchConfig{}, nil) cl.EXPECT().SafeBrowsing() - cl.EXPECT().RewriteList().Return(&types.RewriteEntries{}, nil) - cl.EXPECT().Services() - cl.EXPECT().Filtering().Return(&types.FilteringStatus{}, nil) - cl.EXPECT().Clients().Return(&types.Clients{}, nil) - cl.EXPECT().QueryLogConfig().Return(&types.QueryLogConfig{}, nil) - cl.EXPECT().StatsConfig().Return(&types.IntervalConfig{}, nil) - cl.EXPECT().AccessList().Return(&types.AccessList{}, nil) - cl.EXPECT().DNSConfig().Return(&types.DNSConfig{}, nil) - cl.EXPECT().DHCPServerConfig().Return(&types.DHCPServerConfig{}, nil) + cl.EXPECT().RewriteList().Return(&model.RewriteEntries{}, nil) + cl.EXPECT().BlockedServices() + cl.EXPECT().BlockedServicesSchedule() + cl.EXPECT().Filtering().Return(&model.FilterStatus{}, nil) + cl.EXPECT().Clients().Return(&model.Clients{}, nil) + cl.EXPECT().QueryLogConfig().Return(&model.QueryLogConfig{}, nil) + cl.EXPECT().StatsConfig().Return(&model.StatsConfig{}, nil) + cl.EXPECT().AccessList().Return(&model.AccessList{}, nil) + cl.EXPECT().DNSConfig().Return(&model.DNSConfig{}, nil) + cl.EXPECT().DhcpConfig().Return(&model.DhcpStatus{}, nil) // replica cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: versions.MinAgh}, nil) + cl.EXPECT().Status().Return(&model.ServerStatus{Version: versions.MinAgh}, nil) + cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{}, nil) cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().SafeSearchConfig().Return(&model.SafeSearchConfig{}, nil) cl.EXPECT().SafeBrowsing() - cl.EXPECT().QueryLogConfig().Return(&types.QueryLogConfig{}, nil) - cl.EXPECT().StatsConfig().Return(&types.IntervalConfig{}, nil) - cl.EXPECT().RewriteList().Return(&types.RewriteEntries{}, nil) + cl.EXPECT().QueryLogConfig().Return(&model.QueryLogConfig{}, nil) + cl.EXPECT().StatsConfig().Return(&model.StatsConfig{}, nil) + cl.EXPECT().RewriteList().Return(&model.RewriteEntries{}, nil) cl.EXPECT().AddRewriteEntries() cl.EXPECT().DeleteRewriteEntries() - cl.EXPECT().Filtering().Return(&types.FilteringStatus{}, nil) + cl.EXPECT().Filtering().Return(&model.FilterStatus{}, nil) cl.EXPECT().AddFilters(false) cl.EXPECT().UpdateFilters(false) cl.EXPECT().DeleteFilters(false) cl.EXPECT().AddFilters(true) cl.EXPECT().UpdateFilters(true) cl.EXPECT().DeleteFilters(true) - cl.EXPECT().Services() - cl.EXPECT().Clients().Return(&types.Clients{}, nil) + cl.EXPECT().BlockedServices() + cl.EXPECT().BlockedServicesSchedule() + cl.EXPECT().Clients().Return(&model.Clients{}, nil) cl.EXPECT().AddClients() cl.EXPECT().UpdateClients() cl.EXPECT().DeleteClients() - cl.EXPECT().AccessList().Return(&types.AccessList{}, nil) - cl.EXPECT().DNSConfig().Return(&types.DNSConfig{}, nil) - cl.EXPECT().DHCPServerConfig().Return(&types.DHCPServerConfig{}, nil) + cl.EXPECT().AccessList().Return(&model.AccessList{}, nil) + cl.EXPECT().DNSConfig().Return(&model.DNSConfig{}, nil) + cl.EXPECT().DhcpConfig().Return(&model.DhcpStatus{}, nil) cl.EXPECT().AddDHCPStaticLeases().Return(nil) cl.EXPECT().DeleteDHCPStaticLeases().Return(nil) w.sync() @@ -550,94 +593,78 @@ var _ = Describe("Sync", func() { w.cfg.Features.DHCP.StaticLeases = false // origin cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: versions.MinAgh}, nil) + cl.EXPECT().Status().Return(&model.ServerStatus{Version: versions.MinAgh}, nil) + cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{}, nil) cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().SafeSearchConfig().Return(&model.SafeSearchConfig{}, nil) cl.EXPECT().SafeBrowsing() - cl.EXPECT().RewriteList().Return(&types.RewriteEntries{}, nil) - cl.EXPECT().Services() - cl.EXPECT().Filtering().Return(&types.FilteringStatus{}, nil) - cl.EXPECT().Clients().Return(&types.Clients{}, nil) - cl.EXPECT().QueryLogConfig().Return(&types.QueryLogConfig{}, nil) - cl.EXPECT().StatsConfig().Return(&types.IntervalConfig{}, nil) - cl.EXPECT().AccessList().Return(&types.AccessList{}, nil) - cl.EXPECT().DNSConfig().Return(&types.DNSConfig{}, nil) + cl.EXPECT().RewriteList().Return(&model.RewriteEntries{}, nil) + cl.EXPECT().BlockedServices() + cl.EXPECT().BlockedServicesSchedule() + cl.EXPECT().Filtering().Return(&model.FilterStatus{}, nil) + cl.EXPECT().Clients().Return(&model.Clients{}, nil) + cl.EXPECT().QueryLogConfig().Return(&model.QueryLogConfig{}, nil) + cl.EXPECT().StatsConfig().Return(&model.StatsConfig{}, nil) + cl.EXPECT().AccessList().Return(&model.AccessList{}, nil) + cl.EXPECT().DNSConfig().Return(&model.DNSConfig{}, nil) // replica cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: versions.MinAgh}, nil) + cl.EXPECT().Status().Return(&model.ServerStatus{Version: versions.MinAgh}, nil) + cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{}, nil) cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().SafeSearchConfig().Return(&model.SafeSearchConfig{}, nil) cl.EXPECT().SafeBrowsing() - cl.EXPECT().QueryLogConfig().Return(&types.QueryLogConfig{}, nil) - cl.EXPECT().StatsConfig().Return(&types.IntervalConfig{}, nil) - cl.EXPECT().RewriteList().Return(&types.RewriteEntries{}, nil) + cl.EXPECT().QueryLogConfig().Return(&model.QueryLogConfig{}, nil) + cl.EXPECT().StatsConfig().Return(&model.StatsConfig{}, nil) + cl.EXPECT().RewriteList().Return(&model.RewriteEntries{}, nil) cl.EXPECT().AddRewriteEntries() cl.EXPECT().DeleteRewriteEntries() - cl.EXPECT().Filtering().Return(&types.FilteringStatus{}, nil) + cl.EXPECT().Filtering().Return(&model.FilterStatus{}, nil) cl.EXPECT().AddFilters(false) cl.EXPECT().UpdateFilters(false) cl.EXPECT().DeleteFilters(false) cl.EXPECT().AddFilters(true) cl.EXPECT().UpdateFilters(true) cl.EXPECT().DeleteFilters(true) - cl.EXPECT().Services() - cl.EXPECT().Clients().Return(&types.Clients{}, nil) + cl.EXPECT().BlockedServices() + cl.EXPECT().BlockedServicesSchedule() + cl.EXPECT().Clients().Return(&model.Clients{}, nil) cl.EXPECT().AddClients() cl.EXPECT().UpdateClients() cl.EXPECT().DeleteClients() - cl.EXPECT().AccessList().Return(&types.AccessList{}, nil) - cl.EXPECT().DNSConfig().Return(&types.DNSConfig{}, nil) + cl.EXPECT().AccessList().Return(&model.AccessList{}, nil) + cl.EXPECT().DNSConfig().Return(&model.DNSConfig{}, nil) w.sync() }) It("origin version is too small", func() { // origin cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: "v0.106.9"}, nil) + cl.EXPECT().Status().Return(&model.ServerStatus{Version: "v0.106.9"}, nil) w.sync() }) It("replica version is too small", func() { // origin cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: versions.MinAgh}, nil) + cl.EXPECT().Status().Return(&model.ServerStatus{Version: versions.MinAgh}, nil) + cl.EXPECT().ProfileInfo().Return(&model.ProfileInfo{}, nil) cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() + cl.EXPECT().SafeSearchConfig().Return(&model.SafeSearchConfig{}, nil) cl.EXPECT().SafeBrowsing() - cl.EXPECT().RewriteList().Return(&types.RewriteEntries{}, nil) - cl.EXPECT().Services() - cl.EXPECT().Filtering().Return(&types.FilteringStatus{}, nil) - cl.EXPECT().Clients().Return(&types.Clients{}, nil) - cl.EXPECT().QueryLogConfig().Return(&types.QueryLogConfig{}, nil) - cl.EXPECT().StatsConfig().Return(&types.IntervalConfig{}, nil) - cl.EXPECT().AccessList().Return(&types.AccessList{}, nil) - cl.EXPECT().DNSConfig().Return(&types.DNSConfig{}, nil) - cl.EXPECT().DHCPServerConfig().Return(&types.DHCPServerConfig{}, nil) + cl.EXPECT().RewriteList().Return(&model.RewriteEntries{}, nil) + cl.EXPECT().BlockedServices() + cl.EXPECT().BlockedServicesSchedule() + cl.EXPECT().Filtering().Return(&model.FilterStatus{}, nil) + cl.EXPECT().Clients().Return(&model.Clients{}, nil) + cl.EXPECT().QueryLogConfig().Return(&model.QueryLogConfig{}, nil) + cl.EXPECT().StatsConfig().Return(&model.StatsConfig{}, nil) + cl.EXPECT().AccessList().Return(&model.AccessList{}, nil) + cl.EXPECT().DNSConfig().Return(&model.DNSConfig{}, nil) + cl.EXPECT().DhcpConfig().Return(&model.DhcpStatus{}, nil) // replica cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: "v0.106.9"}, nil) - w.sync() - }) - It("replica version is with incompatible API", func() { - // origin - cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: versions.MinAgh}, nil) - cl.EXPECT().Parental() - cl.EXPECT().SafeSearch() - cl.EXPECT().SafeBrowsing() - cl.EXPECT().RewriteList().Return(&types.RewriteEntries{}, nil) - cl.EXPECT().Services() - cl.EXPECT().Filtering().Return(&types.FilteringStatus{}, nil) - cl.EXPECT().Clients().Return(&types.Clients{}, nil) - cl.EXPECT().QueryLogConfig().Return(&types.QueryLogConfig{}, nil) - cl.EXPECT().StatsConfig().Return(&types.IntervalConfig{}, nil) - cl.EXPECT().AccessList().Return(&types.AccessList{}, nil) - cl.EXPECT().DNSConfig().Return(&types.DNSConfig{}, nil) - cl.EXPECT().DHCPServerConfig().Return(&types.DHCPServerConfig{}, nil) - - // replica - cl.EXPECT().Host() - cl.EXPECT().Status().Return(&types.Status{Version: versions.IncompatibleAPI}, nil) + cl.EXPECT().Status().Return(&model.ServerStatus{Version: "v0.106.9"}, nil) w.sync() }) }) diff --git a/pkg/types/deepcopy_generated.go b/pkg/types/deepcopy_generated.go index d58a421..71dfa4c 100644 --- a/pkg/types/deepcopy_generated.go +++ b/pkg/types/deepcopy_generated.go @@ -5,10 +5,6 @@ package types -import ( - net "net" -) - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AdGuardInstance) DeepCopyInto(out *AdGuardInstance) { *out = *in @@ -60,44 +56,3 @@ func (in *Config) DeepCopy() *Config { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *DNSConfig) DeepCopyInto(out *DNSConfig) { - *out = *in - if in.Upstreams != nil { - in, out := &in.Upstreams, &out.Upstreams - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Bootstraps != nil { - in, out := &in.Bootstraps, &out.Bootstraps - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.BlockingIPv4 != nil { - in, out := &in.BlockingIPv4, &out.BlockingIPv4 - *out = make(net.IP, len(*in)) - copy(*out, *in) - } - if in.BlockingIPv6 != nil { - in, out := &in.BlockingIPv6, &out.BlockingIPv6 - *out = make(net.IP, len(*in)) - copy(*out, *in) - } - if in.LocalPTRUpstreams != nil { - in, out := &in.LocalPTRUpstreams, &out.LocalPTRUpstreams - *out = make([]string, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DNSConfig. -func (in *DNSConfig) DeepCopy() *DNSConfig { - if in == nil { - return nil - } - out := new(DNSConfig) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/types/dhcp.go b/pkg/types/dhcp.go deleted file mode 100644 index b63b516..0000000 --- a/pkg/types/dhcp.go +++ /dev/null @@ -1,101 +0,0 @@ -package types - -import ( - "encoding/json" - "net" - "time" - - "github.com/jinzhu/copier" -) - -// DHCPServerConfig dhcp server config -type DHCPServerConfig struct { - V4 *V4ServerConfJSON `json:"v4"` - V6 *V6ServerConfJSON `json:"v6"` - InterfaceName string `json:"interface_name"` - Enabled bool `json:"enabled"` - - Leases Leases `json:"leases,omitempty"` - StaticLeases Leases `json:"static_leases,omitempty"` -} - -// Clone the config -func (c *DHCPServerConfig) Clone() *DHCPServerConfig { - clone := &DHCPServerConfig{} - _ = copier.Copy(clone, c) - return clone -} - -// Equals dhcp server config equal check -func (c *DHCPServerConfig) Equals(o *DHCPServerConfig) bool { - a, _ := json.Marshal(c) - b, _ := json.Marshal(o) - return string(a) == string(b) -} - -func (c *DHCPServerConfig) HasConfig() bool { - return (c.V4 != nil && c.V4.isValid()) || (c.V6 != nil && c.V6.isValid()) -} - -// V4ServerConfJSON v4 server conf -type V4ServerConfJSON struct { - GatewayIP net.IP `json:"gateway_ip"` - SubnetMask net.IP `json:"subnet_mask"` - RangeStart net.IP `json:"range_start"` - RangeEnd net.IP `json:"range_end"` - LeaseDuration uint32 `json:"lease_duration"` -} - -func (j V4ServerConfJSON) isValid() bool { - return j.GatewayIP != nil && j.SubnetMask != nil && j.RangeStart != nil && j.RangeEnd != nil -} - -// V6ServerConfJSON v6 server conf -type V6ServerConfJSON struct { - RangeStart net.IP `json:"range_start"` - RangeEnd net.IP `json:"range_end"` - LeaseDuration uint32 `json:"lease_duration"` -} - -func (j V6ServerConfJSON) isValid() bool { - return j.RangeStart != nil && j.RangeEnd != nil -} - -// Leases slice of leases type -type Leases []Lease - -// Merge the leases -func (l Leases) Merge(other Leases) ([]Lease, []Lease) { - current := make(map[string]Lease) - - var adds Leases - var removes Leases - for _, le := range l { - current[le.HWAddr] = le - } - - for _, le := range other { - if _, ok := current[le.HWAddr]; ok { - delete(current, le.HWAddr) - } else { - adds = append(adds, le) - } - } - - for _, rr := range current { - removes = append(removes, rr) - } - - return adds, removes -} - -// Lease contains the necessary information about a DHCP lease -type Lease struct { - HWAddr string `json:"mac"` - IP net.IP `json:"ip"` - Hostname string `json:"hostname"` - - // Lease expiration time - // 1: static lease - Expiry time.Time `json:"expires"` -} diff --git a/pkg/types/dns.go b/pkg/types/dns.go deleted file mode 100644 index 29422e8..0000000 --- a/pkg/types/dns.go +++ /dev/null @@ -1,71 +0,0 @@ -package types - -import ( - "encoding/json" - "net" - "sort" -) - -// DNSConfig dns config -// +k8s:deepcopy-gen=true -type DNSConfig struct { - Upstreams []string `json:"upstream_dns,omitempty"` - UpstreamsFile string `json:"upstream_dns_file"` - Bootstraps []string `json:"bootstrap_dns,omitempty"` - - ProtectionEnabled bool `json:"protection_enabled"` - RateLimit uint32 `json:"ratelimit"` - BlockingMode string `json:"blocking_mode,omitempty"` - BlockingIPv4 net.IP `json:"blocking_ipv4,omitempty"` - BlockingIPv6 net.IP `json:"blocking_ipv6"` - EDNSCSEnabled bool `json:"edns_cs_enabled"` - DNSSECEnabled bool `json:"dnssec_enabled"` - DisableIPv6 bool `json:"disable_ipv6"` - UpstreamMode string `json:"upstream_mode,omitempty"` - CacheSize uint32 `json:"cache_size"` - CacheMinTTL uint32 `json:"cache_ttl_min"` - CacheMaxTTL uint32 `json:"cache_ttl_max"` - CacheOptimistic bool `json:"cache_optimistic"` - ResolveClients bool `json:"resolve_clients"` - LocalPTRUpstreams []string `json:"local_ptr_upstreams,omitempty"` -} - -// Equals dns config equal check -func (c *DNSConfig) Equals(o *DNSConfig) bool { - cc := c.DeepCopy() - oo := o.DeepCopy() - cc.Sort() - oo.Sort() - - a, _ := json.Marshal(cc) - b, _ := json.Marshal(oo) - return string(a) == string(b) -} - -// Sort sort dns config -func (c *DNSConfig) Sort() { - sort.Strings(c.Upstreams) - sort.Strings(c.Bootstraps) - sort.Strings(c.LocalPTRUpstreams) -} - -// AccessList access list -type AccessList struct { - AllowedClients []string `json:"allowed_clients"` - DisallowedClients []string `json:"disallowed_clients"` - BlockedHosts []string `json:"blocked_hosts"` -} - -// Equals access list equal check -func (al *AccessList) Equals(o *AccessList) bool { - return equals(al.AllowedClients, o.AllowedClients) && - equals(al.DisallowedClients, o.DisallowedClients) && - equals(al.BlockedHosts, o.BlockedHosts) -} - -// Sort sort access list -func (al *AccessList) Sort() { - sort.Strings(al.AllowedClients) - sort.Strings(al.DisallowedClients) - sort.Strings(al.BlockedHosts) -} diff --git a/pkg/types/features.go b/pkg/types/features.go index 99e88d3..3587411 100644 --- a/pkg/types/features.go +++ b/pkg/types/features.go @@ -60,7 +60,7 @@ func (f *Features) LogDisabled(l *zap.SugaredLogger) { features = append(features, "ClientSettings") } if !f.Services { - features = append(features, "Services") + features = append(features, "BlockedServices") } if !f.Filters { features = append(features, "Filters") diff --git a/pkg/types/types.go b/pkg/types/types.go index 8680c78..ed830ce 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -1,12 +1,8 @@ package types import ( - "encoding/json" "fmt" - "sort" - "strings" - "github.com/bakito/adguardhome-sync/pkg/versions" "go.uber.org/zap" ) @@ -111,308 +107,6 @@ type Protection struct { ProtectionEnabled bool `json:"protection_enabled"` } -// Status API struct -type Status struct { - Protection - DNSAddresses []string `json:"dns_addresses"` - DNSPort int `json:"dns_port"` - HTTPPort int `json:"http_port"` - DhcpAvailable bool `json:"dhcp_available"` - Running bool `json:"running"` - Version string `json:"version"` - Language string `json:"language"` -} - -// RewriteEntries list of RewriteEntry -type RewriteEntries []RewriteEntry - -// Merge RewriteEntries -func (rwe *RewriteEntries) Merge(other *RewriteEntries) (RewriteEntries, RewriteEntries, RewriteEntries) { - current := make(map[string]RewriteEntry) - - var adds RewriteEntries - var removes RewriteEntries - var duplicates RewriteEntries - processed := make(map[string]bool) - for _, rr := range *rwe { - if _, ok := processed[rr.Key()]; !ok { - current[rr.Key()] = rr - processed[rr.Key()] = true - } else { - // remove duplicate - removes = append(removes, rr) - } - } - - for _, rr := range *other { - if _, ok := current[rr.Key()]; ok { - delete(current, rr.Key()) - } else { - if _, ok := processed[rr.Key()]; !ok { - adds = append(adds, rr) - processed[rr.Key()] = true - } else { - // skip duplicate - duplicates = append(duplicates, rr) - } - } - } - - for _, rr := range current { - removes = append(removes, rr) - } - - return adds, removes, duplicates -} - -// RewriteEntry API struct -type RewriteEntry struct { - Domain string `json:"domain"` - Answer string `json:"answer"` -} - -// Key RewriteEntry key -func (re *RewriteEntry) Key() string { - return fmt.Sprintf("%s#%s", re.Domain, re.Answer) -} - -// Filters list of Filter -type Filters []Filter - -// Merge merge Filters -func (f Filters) Merge(other Filters) (Filters, Filters, Filters) { - current := make(map[string]Filter) - - var adds Filters - var updates Filters - var removes Filters - for _, f := range f { - current[f.URL] = f - } - - for i := range other { - rr := other[i] - if c, ok := current[rr.URL]; ok { - if !c.Equals(&rr) { - updates = append(updates, rr) - } - delete(current, rr.URL) - } else { - adds = append(adds, rr) - } - } - - for _, rr := range current { - removes = append(removes, rr) - } - - return adds, updates, removes -} - -// Filter API struct -type Filter struct { - ID int `json:"id"` - Enabled bool `json:"enabled"` - URL string `json:"url"` // needed for add - Name string `json:"name"` // needed for add - RulesCount int `json:"rules_count"` - Whitelist bool `json:"whitelist"` // needed for add -} - -// Equals Filter equal check -func (f *Filter) Equals(o *Filter) bool { - return f.Enabled == o.Enabled && f.URL == o.URL && f.Name == o.Name -} - -// FilterUpdate API struct -type FilterUpdate struct { - URL string `json:"url"` - Data Filter `json:"data"` - Whitelist bool `json:"whitelist"` -} - -// FilteringStatus API struct -type FilteringStatus struct { - FilteringConfig - Filters Filters `json:"filters"` - WhitelistFilters Filters `json:"whitelist_filters"` - UserRules UserRules `json:"user_rules"` -} - -// UserRules API struct -type UserRules []string - -// String toString of Users -func (ur UserRules) String() string { - return strings.Join(ur, "\n") -} - -// ToPayload return the version specific payload for user rules -func (ur UserRules) ToPayload(version string) interface{} { - if versions.IsNewerThan(version, versions.LastStringCustomRules) { - return &UserRulesRequest{Rules: ur} - } - return ur.String() -} - -// UserRulesRequest API struct -type UserRulesRequest struct { - Rules UserRules -} - -// String toString of Users -func (ur UserRulesRequest) String() string { - return ur.Rules.String() -} - -// EnableConfig API struct -type EnableConfig struct { - Enabled bool `json:"enabled"` -} - -// IntervalConfig API struct -type IntervalConfig struct { - Interval float64 `json:"interval"` -} - -// FilteringConfig API struct -type FilteringConfig struct { - EnableConfig - IntervalConfig -} - -// QueryLogConfig API struct -type QueryLogConfig struct { - EnableConfig - IntervalConfig - AnonymizeClientIP bool `json:"anonymize_client_ip"` -} - -// Equals QueryLogConfig equal check -func (qlc *QueryLogConfig) Equals(o *QueryLogConfig) bool { - return qlc.Enabled == o.Enabled && qlc.AnonymizeClientIP == o.AnonymizeClientIP && qlc.Interval == o.Interval -} - -// RefreshFilter API struct -type RefreshFilter struct { - Whitelist bool `json:"whitelist"` -} - -// Services API struct -type Services []string - -// Sort sort Services -func (s Services) Sort() { - sort.Strings(s) -} - -// Equals Services equal check -func (s Services) Equals(o Services) bool { - s.Sort() - o.Sort() - return equals(s, o) -} - -// Clients API struct -type Clients struct { - Clients []Client `json:"clients"` - AutoClients []struct { - IP string `json:"ip"` - Name string `json:"name"` - Source string `json:"source"` - WhoisInfo struct{} `json:"whois_info"` - } `json:"auto_clients"` - SupportedTags []string `json:"supported_tags"` -} - -// Client API struct -type Client struct { - Ids []string `json:"ids,omitempty"` - Tags []string `json:"tags,omitempty"` - BlockedServices []string `json:"blocked_services,omitempty"` - Upstreams []string `json:"upstreams,omitempty"` - - UseGlobalSettings bool `json:"use_global_settings"` - UseGlobalBlockedServices bool `json:"use_global_blocked_services"` - Name string `json:"name"` - FilteringEnabled bool `json:"filtering_enabled"` - ParentalEnabled bool `json:"parental_enabled"` - SafesearchEnabled bool `json:"safesearch_enabled"` - SafebrowsingEnabled bool `json:"safebrowsing_enabled"` - Disallowed bool `json:"disallowed"` - DisallowedRule string `json:"disallowed_rule"` -} - -// Sort sort clients -func (cl *Client) Sort() { - sort.Strings(cl.Ids) - sort.Strings(cl.Tags) - sort.Strings(cl.BlockedServices) - sort.Strings(cl.Upstreams) -} - -// Equals Clients equal check -func (cl *Client) Equals(o *Client) bool { - cl.Sort() - o.Sort() - - a, _ := json.Marshal(cl) - b, _ := json.Marshal(o) - return string(a) == string(b) -} - -// Merge merge Clients -func (clients *Clients) Merge(other *Clients) ([]Client, []Client, []Client) { - current := make(map[string]Client) - for _, client := range clients.Clients { - current[client.Name] = client - } - - expected := make(map[string]Client) - for _, client := range other.Clients { - expected[client.Name] = client - } - - var adds []Client - var removes []Client - var updates []Client - - for _, cl := range expected { - if oc, ok := current[cl.Name]; ok { - if !cl.Equals(&oc) { - updates = append(updates, cl) - } - delete(current, cl.Name) - } else { - adds = append(adds, cl) - } - } - - for _, rr := range current { - removes = append(removes, rr) - } - - return adds, updates, removes -} - -// ClientUpdate API struct -type ClientUpdate struct { - Name string `json:"name"` - Data Client `json:"data"` -} - -func equals(a []string, b []string) bool { - if len(a) != len(b) { - return false - } - for i, v := range a { - if v != b[i] { - return false - } - } - return true -} - // InstallConfig AdguardHome install config type InstallConfig struct { Web InstallPort `json:"web"` diff --git a/pkg/utils/clone.go b/pkg/utils/clone.go new file mode 100644 index 0000000..ae0c1a8 --- /dev/null +++ b/pkg/utils/clone.go @@ -0,0 +1,15 @@ +package utils + +import "encoding/json" + +func Clone[I interface{}](in I, out I) I { + b, _ := json.Marshal(in) + _ = json.Unmarshal(b, out) + return out +} + +func JsonEquals(a interface{}, b interface{}) bool { + ja, _ := json.Marshal(a) + jb, _ := json.Marshal(b) + return string(ja) == string(jb) +} diff --git a/pkg/utils/ptr.go b/pkg/utils/ptr.go new file mode 100644 index 0000000..3e2ae85 --- /dev/null +++ b/pkg/utils/ptr.go @@ -0,0 +1,14 @@ +package utils + +import "fmt" + +func Ptr[I interface{}](i I) *I { + return &i +} + +func PtrToString[I interface{}](i *I) string { + if i == nil { + return "" + } + return fmt.Sprintf("%v", i) +} diff --git a/pkg/versions/versions.go b/pkg/versions/versions.go index 6ad9416..d7978b6 100644 --- a/pkg/versions/versions.go +++ b/pkg/versions/versions.go @@ -4,16 +4,7 @@ import "golang.org/x/mod/semver" const ( // MinAgh minimal adguardhome version - MinAgh = "v0.107.0" - // LastStringCustomRules last adguardhome version with string payload custom rules - // https://github.com/bakito/adguardhome-sync/issues/99 - LastStringCustomRules = "v0.107.13" - // IncompatibleAPI adguardhome version with incompatible API - // https://github.com/bakito/adguardhome-sync/issues/99 - IncompatibleAPI = "v0.107.14" - // FixedIncompatibleAPI adguardhome version with fixed API - // https://github.com/bakito/adguardhome-sync/issues/99 - FixedIncompatibleAPI = "v0.107.15" + MinAgh = "v0.107.40" ) func IsNewerThan(v1 string, v2 string) bool { diff --git a/testdata/blockedservicesschedule-get.json b/testdata/blockedservicesschedule-get.json new file mode 100644 index 0000000..2eecaf7 --- /dev/null +++ b/testdata/blockedservicesschedule-get.json @@ -0,0 +1,22 @@ +{ + "schedule": { + "time_zone": "Europe/Zurich", + "tue": { + "start": 0, + "end": 86340000 + }, + "thu": { + "start": 0, + "end": 86340000 + }, + "sat": { + "start": 0, + "end": 35940000 + } + }, + "ids": [ + "9gag", + "dailymotion", + "disneyplus" + ] +} \ No newline at end of file diff --git a/testdata/e2e/bin/read-latest-replica-config.sh b/testdata/e2e/bin/read-latest-replica-config.sh new file mode 100755 index 0000000..168eaf9 --- /dev/null +++ b/testdata/e2e/bin/read-latest-replica-config.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e + echo "## AdGuardHome.yaml of latest replica" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + kubectl exec adguardhome-replica-latest -- cat /opt/adguardhome/conf/AdGuardHome.yaml >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY diff --git a/testdata/e2e/resources/AdGuardHome.yaml b/testdata/e2e/resources/AdGuardHome.yaml new file mode 100644 index 0000000..cefbb98 --- /dev/null +++ b/testdata/e2e/resources/AdGuardHome.yaml @@ -0,0 +1,206 @@ +http: + pprof: + port: 6060 + enabled: false + address: 0.0.0.0:3000 + session_ttl: 720h +users: + - name: username + password: $2a$10$yrrX.EvDpUUnZxr74u6euOMeF6dPFd/mEyohDq1LkpH76JyeObPBm +auth_attempts: 5 +block_auth_min: 15 +http_proxy: "" +language: en +theme: auto +dns: + bind_hosts: + - 0.0.0.0 + port: 53 + anonymize_client_ip: false + ratelimit: 20 + ratelimit_whitelist: [ ] + refuse_any: true + upstream_dns: + - https://dns10.quad9.net/dns-query + upstream_dns_file: "" + bootstrap_dns: + - 1.1.1.1:53 + fallback_dns: [ ] + all_servers: false + fastest_addr: false + fastest_timeout: 1s + allowed_clients: [ ] + disallowed_clients: [ ] + blocked_hosts: + - version.bind + - id.server + - hostname.bind + trusted_proxies: + - 127.0.0.0/8 + - ::1/128 + cache_size: 4194304 + cache_ttl_min: 0 + cache_ttl_max: 0 + cache_optimistic: true + bogus_nxdomain: [ ] + aaaa_disabled: false + enable_dnssec: false + edns_client_subnet: + custom_ip: "" + enabled: false + use_custom: false + max_goroutines: 300 + handle_ddr: true + ipset: [ ] + ipset_file: "" + bootstrap_prefer_ipv6: false + upstream_timeout: 10s + private_networks: [ ] + use_private_ptr_resolvers: true + local_ptr_upstreams: [ ] + use_dns64: false + dns64_prefixes: [ ] + serve_http3: false + use_http3_upstreams: false +tls: + enabled: false + server_name: "" + force_https: false + port_https: 443 + port_dns_over_tls: 853 + port_dns_over_quic: 853 + port_dnscrypt: 0 + dnscrypt_config_file: "" + allow_unencrypted_doh: false + certificate_chain: "" + private_key: "" + certificate_path: "" + private_key_path: "" + strict_sni_check: false +querylog: + ignored: [ ] + interval: 6h + size_memory: 1000 + enabled: true + file_enabled: true +statistics: + ignored: [ ] + interval: 24h + enabled: true +filters: + - enabled: true + url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt + name: AdGuard DNS filter + id: 1 + - enabled: true + url: https://adaway.org/hosts.txt + name: AdAway Default Blocklist + id: 2 +whitelist_filters: [ ] +user_rules: + - '||metrics2.data.hicloud.com^$important' + - '||www.curiouscorrespondence.com^$important' + - '||bluewizard.com^$important' + - '||facebook.com^$important' +dhcp: + enabled: false + interface_name: eth0 + local_domain_name: lan + dhcpv4: + gateway_ip: 1.2.3.4 + subnet_mask: 255.255.0.0 + range_start: 1.2.3.5 + range_end: 1.2.3.56 + lease_duration: 86400 + icmp_timeout_msec: 1000 + options: [ ] + dhcpv6: + range_start: "" + lease_duration: 86400 + ra_slaac_only: false + ra_allow_slaac: false +filtering: + blocking_ipv4: "" + blocking_ipv6: "" + blocked_services: + schedule: + time_zone: Europe/Zurich + tue: + start: 0s + end: 23h59m + thu: + start: 0s + end: 23h59m + sat: + start: 0s + end: 9h59m + ids: + - 9gag + - dailymotion + - disneyplus + protection_disabled_until: null + safe_search: + enabled: true + bing: true + duckduckgo: true + google: true + pixabay: true + yandex: true + youtube: true + blocking_mode: default + parental_block_host: family-block.dns.adguard.com + safebrowsing_block_host: standard-block.dns.adguard.com + rewrites: [ ] + safebrowsing_cache_size: 1048576 + safesearch_cache_size: 1048576 + parental_cache_size: 1048576 + cache_time: 30 + filters_update_interval: 24 + blocked_response_ttl: 10 + filtering_enabled: true + parental_enabled: true + safebrowsing_enabled: true + protection_enabled: true +clients: + runtime_sources: + whois: true + arp: true + rdns: true + dhcp: true + hosts: true + persistent: + - name: Device 1 + tags: + - device_1 + ids: + - 2.2.2.2 + blocked_services: + schedule: + time_zone: Europe/Zurich + ids: + - facebook + - mail_ru + - qq + - vk + - ok + upstreams: [ ] + use_global_settings: true + filtering_enabled: false + parental_enabled: false + safebrowsing_enabled: false + use_global_blocked_services: false + ignore_querylog: false + ignore_statistics: false +log: + file: "" + max_backups: 0 + max_size: 100 + max_age: 3 + compress: false + local_time: false + verbose: false +os: + group: "" + user: "" + rlimit_nofile: 0 +schema_version: 27 diff --git a/testdata/e2e/templates/NOTES.txt b/testdata/e2e/templates/NOTES.txt new file mode 100644 index 0000000..98309e7 --- /dev/null +++ b/testdata/e2e/templates/NOTES.txt @@ -0,0 +1,4 @@ +Installed adguardhome-sync end-2-end test with {{ len .Values.replica.versions }} replica instances. +{{- range $_, $version := .Values.replica.versions }} + - {{ $version }} +{{- end }} diff --git a/testdata/e2e/templates/configmap-origin.yaml b/testdata/e2e/templates/configmap-origin.yaml index 38dbdfb..e928049 100644 --- a/testdata/e2e/templates/configmap-origin.yaml +++ b/testdata/e2e/templates/configmap-origin.yaml @@ -5,170 +5,4 @@ metadata: namespace: {{ .Release.Namespace }} data: AdGuardHome.yaml: | - bind_host: 0.0.0.0 - bind_port: 3000 - beta_bind_port: 0 - users: - - name: username - password: $2a$10$yrrX.EvDpUUnZxr74u6euOMeF6dPFd/mEyohDq1LkpH76JyeObPBm - auth_attempts: 5 - block_auth_min: 15 - http_proxy: "" - language: en - debug_pprof: false - web_session_ttl: 720 - dns: - bind_hosts: - - 0.0.0.0 - port: 53 - statistics_interval: 1 - querylog_enabled: true - querylog_file_enabled: true - querylog_interval: 6h - querylog_size_memory: 1000 - anonymize_client_ip: false - protection_enabled: true - blocking_mode: default - blocking_ipv4: "" - blocking_ipv6: "" - blocked_response_ttl: 10 - parental_block_host: family-block.dns.adguard.com - safebrowsing_block_host: standard-block.dns.adguard.com - ratelimit: 20 - ratelimit_whitelist: [] - refuse_any: true - upstream_dns: - - https://dns10.quad9.net/dns-query - upstream_dns_file: "" - bootstrap_dns: - - 1.1.1.1:53 - all_servers: false - fastest_addr: false - fastest_timeout: 1s - allowed_clients: [] - disallowed_clients: [] - blocked_hosts: - - version.bind - - id.server - - hostname.bind - trusted_proxies: - - 127.0.0.0/8 - - ::1/128 - cache_size: 4194304 - cache_ttl_min: 0 - cache_ttl_max: 0 - cache_optimistic: true - bogus_nxdomain: [] - aaaa_disabled: false - enable_dnssec: false - edns_client_subnet: false - max_goroutines: 300 - handle_ddr: true - ipset: [] - ipset_file: "" - filtering_enabled: true - filters_update_interval: 12 - parental_enabled: true - safesearch_enabled: true - safebrowsing_enabled: true - safebrowsing_cache_size: 1048576 - safesearch_cache_size: 1048576 - parental_cache_size: 1048576 - cache_time: 30 - rewrites: - - domain: foo.bar.com - answer: 1.2.3.4 - blocked_services: - - 9gag - - dailymotion - upstream_timeout: 10s - private_networks: [] - use_private_ptr_resolvers: true - local_ptr_upstreams: [] - serve_http3: false - use_http3_upstreams: false - tls: - enabled: false - server_name: "" - force_https: false - port_https: 443 - port_dns_over_tls: 853 - port_dns_over_quic: 853 - port_dnscrypt: 0 - dnscrypt_config_file: "" - allow_unencrypted_doh: false - strict_sni_check: false - certificate_chain: "" - private_key: "" - certificate_path: "" - private_key_path: "" - filters: - - enabled: true - url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt - name: AdGuard DNS filter - id: 1 - - enabled: true - url: https://adaway.org/hosts.txt - name: AdAway Default Blocklist - id: 2 - whitelist_filters: [] - user_rules: - - '||metrics2.data.hicloud.com^$important' - - '||www.curiouscorrespondence.com^$important' - - '||bluewizard.com^$important' - - '||facebook.com^$important' - dhcp: - enabled: false - interface_name: eth0 - local_domain_name: lan - dhcpv4: - gateway_ip: 1.2.3.4 - subnet_mask: 255.255.0.0 - range_start: 1.2.3.5 - range_end: 1.2.3.56 - lease_duration: 86400 - icmp_timeout_msec: 1000 - options: [] - dhcpv6: - range_start: "" - lease_duration: 86400 - ra_slaac_only: false - ra_allow_slaac: false - clients: - runtime_sources: - whois: true - arp: true - rdns: true - dhcp: true - hosts: true - persistent: - - name: Device 1 - tags: - - device_1 - ids: - - 2.2.2.2 - blocked_services: - - facebook - - ok - - vk - - mail_ru - - qq - upstreams: [] - use_global_settings: true - filtering_enabled: false - parental_enabled: false - safesearch_enabled: false - safebrowsing_enabled: false - use_global_blocked_services: false - log_file: "" - log_max_backups: 0 - log_max_size: 100 - log_max_age: 3 - log_compress: false - log_localtime: false - verbose: false - os: - group: "" - user: "" - rlimit_nofile: 0 - schema_version: 14 + {{- .Files.Get "resources/AdGuardHome.yaml" | nindent 4 }} \ No newline at end of file diff --git a/testdata/e2e/templates/configmap-sync.yaml b/testdata/e2e/templates/configmap-sync.yaml index 9454927..f647cee 100644 --- a/testdata/e2e/templates/configmap-sync.yaml +++ b/testdata/e2e/templates/configmap-sync.yaml @@ -2,16 +2,16 @@ apiVersion: v1 kind: ConfigMap metadata: name: sync-conf - namespace: {{ .Release.Namespace }} + namespace: {{ .Release.Namespace }} data: - API_PORT: "0" - LOG_LEVEL: info - ORIGIN_URL: http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000 - ORIGIN_PASSWORD: password - ORIGIN_USERNAME: username + API_PORT: '0' + LOG_LEVEL: 'info' + ORIGIN_URL: 'http://service-origin.{{ $.Release.Namespace }}.svc.cluster.local:3000' + ORIGIN_PASSWORD: 'password' + ORIGIN_USERNAME: 'username' {{ range $i,$version := .Values.replica.versions }} - REPLICA{{ $i }}_AUTOSETUP: "true" - REPLICA{{ $i }}_URL: http://service-replica-{{ $version | toString | replace "." "-" }}.{{ $.Release.Namespace }}.svc.cluster.local:3000 - REPLICA{{ $i }}_PASSWORD: password - REPLICA{{ $i }}_USERNAME: username + REPLICA{{ $i }}_AUTOSETUP: 'true' + REPLICA{{ $i }}_URL: 'http://service-replica-{{ $version | toString | replace "." "-" }}.{{ $.Release.Namespace }}.svc.cluster.local:3000' + REPLICA{{ $i }}_PASSWORD: 'password' + REPLICA{{ $i }}_USERNAME: 'username' {{- end }} diff --git a/testdata/e2e/templates/rbac.yaml b/testdata/e2e/templates/rbac.yaml index 8f05a52..8109fa6 100644 --- a/testdata/e2e/templates/rbac.yaml +++ b/testdata/e2e/templates/rbac.yaml @@ -3,7 +3,6 @@ kind: ServiceAccount metadata: name: agh-e2e namespace: {{ .Release.Namespace }} - --- apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [ "" ] resources: [ "pods" ] verbs: [ "get", "watch", "list" ] - --- apiVersion: rbac.authorization.k8s.io/v1 diff --git a/testdata/e2e/values.yaml b/testdata/e2e/values.yaml index 867be52..5ddf650 100644 --- a/testdata/e2e/values.yaml +++ b/testdata/e2e/values.yaml @@ -1,5 +1,4 @@ replica: versions: + - v0.107.40 - latest - - v0.107.13 - - v0.107.15 diff --git a/testdata/filtering-status.json b/testdata/filtering-status.json index fc91e95..266bbfc 100644 --- a/testdata/filtering-status.json +++ b/testdata/filtering-status.json @@ -7,8 +7,7 @@ "enabled": true, "url": "https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt", "name": "AdGuard DNS filter", - "rules_count": 37330, - "last_updated": "" + "rules_count": 37330 }, { "id": 1616956421, @@ -24,4 +23,4 @@ "||metrics2.data.hicloud.com^$important", "" ] -} \ No newline at end of file +}